stuck on this one

G

Guest

I'm trying to find a label and the value within a datalist, i've done this in
the passed in the datalist_itemdatbound routine and worked likes a charm. Now
I"m trying to do the samething in a seperate routine and I can't find the
value.
in the routine i'm getting the value of the checkbox, checked or not and
passing that correctly, I also want to the get a the value of the associated
label with the checkbox and i can't get that working.

I have this:
for I = o to datalist.items.count - 1
checked = datalist.items(I).findcontrol("checkbox")
text = datatlist.items(I).findcontrol("labelname")
value = value & checked.checked.tostring() & text.text.tostring()
next

i'm getting the checkbox value but not the text value.

any ideas why this is happening?
 
M

Michael Tkachev

I writing this in the C#. You will be able to convert it to the VB

CheckBox cb = (CheckBox)datalist.items.Controls.FindControl("checkbox");
bool cval = cb.Checked;
Label lbl = (Label)datalist.items.Controls.FindControl("label");

also you can use code like this:

CheckBox cb = (CheckBox)datalist.items.Controls[0];
bool cval = cb.Checked;
Label lbl = (Label)datalist.items.Controls[1];

in the C# the first control is 0 and in the VB the first control is 1
if your listItem has two controls you have to try to find control 1 and 2

bye
 
G

Guest

thats simialar to what i have and i can't get the label to be recognized:

For I = 0 To datalist.Items.Count - 1
checkbox= dlScores.Items(I).FindControl("chkStuff")
CarInformation= dlScores.Items(G).FindControl("CarStuff")
value = value & checkbox.Checked.ToString() & "|" &
CarInformation.text & "|"
Next I


Michael Tkachev said:
I writing this in the C#. You will be able to convert it to the VB

CheckBox cb = (CheckBox)datalist.items.Controls.FindControl("checkbox");
bool cval = cb.Checked;
Label lbl = (Label)datalist.items.Controls.FindControl("label");

also you can use code like this:

CheckBox cb = (CheckBox)datalist.items.Controls[0];
bool cval = cb.Checked;
Label lbl = (Label)datalist.items.Controls[1];

in the C# the first control is 0 and in the VB the first control is 1
if your listItem has two controls you have to try to find control 1 and 2

bye

Mike said:
I'm trying to find a label and the value within a datalist, i've done this in
the passed in the datalist_itemdatbound routine and worked likes a charm. Now
I"m trying to do the samething in a seperate routine and I can't find the
value.
in the routine i'm getting the value of the checkbox, checked or not and
passing that correctly, I also want to the get a the value of the associated
label with the checkbox and i can't get that working.

I have this:
for I = o to datalist.items.count - 1
checked = datalist.items(I).findcontrol("checkbox")
text = datatlist.items(I).findcontrol("labelname")
value = value & checked.checked.tostring() & text.text.tostring()
next

i'm getting the checkbox value but not the text value.

any ideas why this is happening?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top