Tuesday, March 13, 2012

stuck on this one

I'm trying to find a label and the value within a datalist, i've done this i
n
the passed in the datalist_itemdatbound routine and worked likes a charm. No
w
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?I writing this in the C#. You will be able to convert it to the VB
CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].Controls.FindControl("label");
also you can use code like this:
CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].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" <Mike@.discussions.microsoft.com> wrote in message
news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> 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?
>
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" wrote:

> I writing this in the C#. You will be able to convert it to the VB
> CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].Controls.FindControl("label");
> also you can use code like this:
> CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].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" <Mike@.discussions.microsoft.com> wrote in message
> news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> in
> Now
> associated
>
>

0 comments:

Post a Comment