Note that there are some explanatory texts on larger screens.

plurals
  1. POI need to remove items from a list
    text
    copied!<p>I am making a program that takes user input and populates that into a list. That part is working great. However the user needs the ability to edit or delete his/her input. I cannot figure out how to remove an item from the list. Here is the code for populating the list:</p> <pre><code>[Serializable] class Recipient { public string Fname { get; set; } public string MInit { get; set; } public string Lname { get; set; } public string Suffix { get; set; } public string Amount { get; set; } public string Message { get; set; } public string Custom { get; set; } public string CardType { get; set; } } protected void btnToCart_Click(object sender, EventArgs e) { if (ValidateInput("Card Information")) { SetUI("Your Shopping Cart"); } else { return; } Recipient recipients = new Recipient(); List&lt;string&gt; FName = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; MInit = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; LName = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; Suffix = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; Amount = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; Message = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; Custom = (List&lt;string&gt;)ViewState["recipientList"]; List&lt;string&gt; CardType = (List&lt;string&gt;)ViewState["recipientList"]; if (FName == null &amp;&amp; MInit == null &amp;&amp; LName == null &amp;&amp; Suffix == null &amp;&amp; Amount == null &amp;&amp; Message == null &amp;&amp; Custom == null &amp;&amp; CardType == null) { FName = new List&lt;string&gt;(); MInit = new List&lt;string&gt;(); LName = new List&lt;string&gt;(); Suffix = new List&lt;string&gt;(); Amount = new List&lt;string&gt;(); Message = new List&lt;string&gt;(); Custom = new List&lt;string&gt;(); CardType = new List&lt;string&gt;(); } recipients.Fname = txtFName.Text; recipients.MInit = txtMInit.Text; recipients.Lname = txtLName.Text; recipients.Suffix = ddlSuffix1.SelectedItem.ToString(); recipients.Amount = txtAmount.Text; recipients.Message = ddlMessage.SelectedItem.ToString(); recipients.Custom = txtCustom.Text; recipients.CardType = lblImage.Text; FName.Add(recipients.Fname); MInit.Add(recipients.MInit); LName.Add(recipients.Lname); Suffix.Add(recipients.Suffix); Amount.Add(recipients.Amount); Message.Add(recipients.Message); Custom.Add(recipients.Custom); CardType.Add(recipients.CardType); ViewState["recipientList"] = FName; ViewState["recipientList"] = MInit; ViewState["recipientList"] = LName; ViewState["recipientList"] = Suffix; ViewState["recipientList"] = Amount; ViewState["recipientList"] = Message; ViewState["recipientList"] = Custom; ViewState["recipientList"] = CardType; if (FName.Count == 1 &amp;&amp; MInit.Count == 1 &amp;&amp; LName.Count == 1 &amp;&amp; Suffix.Count == 1) { lblCartName.Text = FName[0] + " " + MInit[0] + " " + LName[0] + " " + Suffix[0]; lnkEdit1.Visible = true; } if (Amount.Count == 1 &amp;&amp; Message.Count == 1 &amp;&amp; Custom.Count == 1) { lblCartAmount.Text = "$" + Amount[0] + ".00"; if (txtCustom.Text == string.Empty) { lblCartMessage.Text = Message[0]; } else { lblCartMessage.Text = Custom[0]; } } </code></pre> <p>Yes there is more to it but anyways, once the user clicks the next button then a summary is displayed to the user with all input information. There is also two linkbuttons on the form that gives the user the choice of editing or deleting. I have tried variations of:</p> <p>FName.Remove(recipients.fname); and FName.RemoveAt(0);for example and none of these have worked. So that is my problem, any help would be greatly appreciated. Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload