|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I set the value of a checkbox on my repeater control?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; } } 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 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 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 > >
Protected Shadows With Events.
dynamic textbox empty string DropDownList with default values Gridview OnPageIndexChanging not firing in beta 2 e.Item.Cells.Count in UpdateCommand event of Datagrid Losing selectedIndex on Control inherted from ListBox during postback Enabled / Disabled my control textbox onfocus event Style tag access webcontrol customizing and fixing web form window size ? |
|||||||||||||||||||||||