C
cally_kalpana
Guest
Hi, this is my code, I have created a list in the event handler, I would now need to call the list user_select_weeks_list in another event handler, how can I do that ? I am a beginner and still learning, I am also interested to know how do programmers create list and use them in their code, is there like a special class where they store and they refer to the class everytime ?
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
List<string> user_select_weeks_list = new List<string>();
for (int i = 0; i < rptItemsInCart.Items.Count; i++)
{
CheckBox ref_to_checkBox = (CheckBox)rptItemsInCart.Items.FindControl("Checkbox1");
if (ref_to_checkBox.Checked)
{
Ok_prompt_to_upload_Button.Visible = true;
ref_to_checkBox.ID = "Week" + (i + 1);
Label2.Text = ref_to_checkBox.ID;
user_select_weeks_list.Add(ref_to_checkBox.ID);
}
}
selected_weeks_repeater.DataSource = user_select_weeks_list;
selected_weeks_repeater.DataBind();
}
I tried changing the signature of the event handler but that gave me an error and upon googling, I found out that's not the right way, what is the right way to do it? Right now, my codes looks so messy with list creation happening at all levels of event handlers, this is just one example.
Continue reading...
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
List<string> user_select_weeks_list = new List<string>();
for (int i = 0; i < rptItemsInCart.Items.Count; i++)
{
CheckBox ref_to_checkBox = (CheckBox)rptItemsInCart.Items.FindControl("Checkbox1");
if (ref_to_checkBox.Checked)
{
Ok_prompt_to_upload_Button.Visible = true;
ref_to_checkBox.ID = "Week" + (i + 1);
Label2.Text = ref_to_checkBox.ID;
user_select_weeks_list.Add(ref_to_checkBox.ID);
}
}
selected_weeks_repeater.DataSource = user_select_weeks_list;
selected_weeks_repeater.DataBind();
}
I tried changing the signature of the event handler but that gave me an error and upon googling, I found out that's not the right way, what is the right way to do it? Right now, my codes looks so messy with list creation happening at all levels of event handlers, this is just one example.
Continue reading...