> Hi....I have a problem.
>
[quoted text clipped - 30 lines]
> Thanks
> Federico
First of all, thans for your reply.
> One problem I can see with the sample code is that the 'control'
> parameter is passed as a value instead of a reference.
Yes, I know, but it works with any other type of control...try drop
down lists or radiolists, I never had the need to pass the argument by
rerefence....
By the way...I tried your suggestion and there is no difference.
On the other way....if I try to get the values of the CheckBoxList on
the server side, it works, I can get the selected values but, in the
resulting html page, there is no property named value, so I assume it
is stored in the viewstate of the asp page.
The reason of this:
> item.Attributes.Add("value",Cod);
is because there is no value property for the checkboxes in the list,
so I tried to manually add it.
You said that potentially I could obtain a duplicate value property
but, unfortunately, none of them is displayed in the page.
I reduced the code to this:
private void CaricaCheckBoxList(ref
System.Web.UI.WebControls.CheckBoxList ChkLstControl)
{
ChkLstControl.Items.Clear();
for (int i=0; i<10; i++)
{
string Val = "Value" + i.ToString();
string Txt = "Text" + i.ToString();
ChkLstControl.Items.Add(new
System.Web.UI.WebControls.ListItem(Txt, Val));
}
}
but the result is the same :(
Just wanted to say....it's very simple to verify the problem:
add a checkboxlist to a webform.
Even if you add items to the collection with text and values directly
from the design view, without filling the control at runtime, you
still get no value property in the resulting html page.
Try it yourself