Home All Groups Group Topic Archive Search About

How do I set the value of a checkbox on my repeater control?

Author
22 Apr 2005 6:42 PM
aaa
Hi,

I have a  repeater that is assign an object and cranks out a bunch of
checkboxes.
That part works fine. In the object I am also passing over the values to
switch the checkboxes on and off.

How do I do that after the fact? I have tried looping thu after the
datasource is assigned but that doen't work.
And also how do I access each of the textbox controls by name if I don't
know what the name of the control is?

   rptr.DataSource = _myobject;
    rptr.DataBind();


    foreach (RepeaterItem ri in rptr.Items)
    {
     CheckBox cbx = (CheckBox)ri.FindControl("ctl14_Checkbox_1");

      if (cbx !=null)
      {
       cbx.Checked = true;
      }

    }

Author
23 Apr 2005 10:13 AM
Tien Do via DotNetMonster.com
No, you can't do that way before the page is not rendered immediately after
DataBind call.

Instead of you should handle ItemDataBound event of repeater and access its
item data.

----------------------------
Tiendq
http://www.nethoa.com
Author
25 Apr 2005 1:07 PM
aaa
That's one piece of the puzzle thnx.
But how do I reference an individual checkbox when I do not know what it's
name is yet?


Show quoteHide quote
"Tien Do via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:06edc2c803824c97bb491c7c93e606af@DotNetMonster.com...
> No, you can't do that way before the page is not rendered immediately
after
> DataBind call.
>
> Instead of you should handle ItemDataBound event of repeater and access
its
> item data.
>
> ----------------------------
> Tiendq
> http://www.nethoa.com
Author
25 Apr 2005 1:24 PM
aaa
nevermind... thanks for all of your help!


Show quoteHide quote
"aaa" <some***@microsoft.com> wrote in message
news:OOOu9eZSFHA.3460@TK2MSFTNGP10.phx.gbl...
> That's one piece of the puzzle thnx.
> But how do I reference an individual checkbox when I do not know what it's
> name is yet?
>
>
> "Tien Do via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
> news:06edc2c803824c97bb491c7c93e606af@DotNetMonster.com...
> > No, you can't do that way before the page is not rendered immediately
> after
> > DataBind call.
> >
> > Instead of you should handle ItemDataBound event of repeater and access
> its
> > item data.
> >
> > ----------------------------
> > Tiendq
> > http://www.nethoa.com
>
>