G
Gan Forr
Hi....I have a problem.
I created a CheckBoxList on a web form, but...when I populate it....in
the resulting Html page there is no value in every checkboxlist item.
I did something like this (suppose that I pass the CheckBoxList as
parameter):
private void
PopulateCheckBoxList(System.Web.UI.WebControls.CheckBoxList control)
{
control.Items.Clear();
for (int i=0; i<10; i++)
{
string Cod = "Value" + i.ToString();
string Text = "Text" + i.ToString();
ListItem item = new ListItem();
item.Text = Text;
item.Value = Cod;
item.Attributes.Add("value",Cod);
control.Items.Add(item);
//control.Items.Add(new System.Web.UI.WebControls.ListItem(Text,
Cod));
}
}
I noticed that the checked values are actually present when I get them
from the c# code, but I need to have them in the html page too. I
tried to add manually the "value" attribute as you can see but I
couldn't get the value in the web page.
I hope somebody can help me
Thanks
Federico
I created a CheckBoxList on a web form, but...when I populate it....in
the resulting Html page there is no value in every checkboxlist item.
I did something like this (suppose that I pass the CheckBoxList as
parameter):
private void
PopulateCheckBoxList(System.Web.UI.WebControls.CheckBoxList control)
{
control.Items.Clear();
for (int i=0; i<10; i++)
{
string Cod = "Value" + i.ToString();
string Text = "Text" + i.ToString();
ListItem item = new ListItem();
item.Text = Text;
item.Value = Cod;
item.Attributes.Add("value",Cod);
control.Items.Add(item);
//control.Items.Add(new System.Web.UI.WebControls.ListItem(Text,
Cod));
}
}
I noticed that the checked values are actually present when I get them
from the c# code, but I need to have them in the html page too. I
tried to add manually the "value" attribute as you can see but I
couldn't get the value in the web page.
I hope somebody can help me
Thanks
Federico