|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TemplateColumn with CheckBox DataBind in C#Hi!
I'm having problem binding a checkbox to data from a DataSet. I've seen solutions like <%#DataBinder.Eval(Container.DataItem, "ColumnToBind")%> but this code must be added in aspx file and I'm generating the datagrid from code behind. How can i bind data from a dataset to a templatecolumn with ckeckbox in code behind? I'm using C# /thanks You can make any special data binding in
datagrid_ItemDataBound event. HTH Elton WAng elton_w***@hotmail.com >-----Original Message----- file and I'm>Hi! > >I'm having problem binding a checkbox to data from a DataSet. > >I've seen solutions like <%#DataBinder.Eval (Container.DataItem, >"ColumnToBind")%> but this code must be added in aspx Show quoteHide quote >generating the datagrid from code behind. > >How can i bind data from a dataset to a templatecolumn with ckeckbox >in code behind? I'm using C# > >/thanks >. > thx... solved the problem with following code in ItemDataBound event.help...
protected override void OnItemDataBound(DataGridItemEventArgs e) { try { string myStr; if((e.Item.ItemType != ListItemType.Header) & (e.Item.ItemType != ListItemType.Footer)) { myStr = Convert.ToString(DataBinder.Eval(e.Item.DataItem,"RegisterVisit")); if (myStr == String.Empty) ((CheckBox)e.Item.Cells[4].Controls[0]).Visible = false; else { ((CheckBox)e.Item.Cells[4].Controls[0]).Checked = Convert.ToBoolean(myStr); } } } catch(Exception E) { } base.OnItemDataBound (e); } Show quoteHide quote "Elton Wang" <anonym***@discussions.microsoft.com> wrote in message news:<1e8a01c51cfa$5b413910$a401280a@phx.gbl>... > You can make any special data binding in > datagrid_ItemDataBound event. > > HTH > > Elton WAng > elton_w***@hotmail.com > > >-----Original Message----- > >Hi! > > > >I'm having problem binding a checkbox to data from a > DataSet. > > > >I've seen solutions like <%#DataBinder.Eval > (Container.DataItem, > >"ColumnToBind")%> but this code must be added in aspx > file and I'm > >generating the datagrid from code behind. > > > >How can i bind data from a dataset to a templatecolumn > with ckeckbox > >in code behind? I'm using C# > > > >/thanks > >. > >
Dynamically created control in Datagrid problem
Select button in datagrid Datagrid Add new Row problkem Condition Edit Action generate DataGrid at Runtime..... PROBLEM !!!! Paging Problem GUI of Datagrid To stop text wraping in an datagrid asp.net 2003 MSDN UNIVERSAL NG SUPPORT: Where Are You?! <--- 3rd Re-Post Datagrid Edit DropdownList Help! |
|||||||||||||||||||||||