Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > TemplateColumn with CheckBox DataBind in C#

Reply
Thread Tools

TemplateColumn with CheckBox DataBind in C#

 
 
Qemajl
Guest
Posts: n/a
 
      02-26-2005
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
 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      02-27-2005
You can make any special data binding in
datagrid_ItemDataBound event.

HTH

Elton WAng


>-----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
>.
>

 
Reply With Quote
 
 
 
 
Qemajl
Guest
Posts: n/a
 
      02-28-2005
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);
}
"Elton Wang" <> wrote in message news:<1e8a01c51cfa$5b413910$>...
> You can make any special data binding in
> datagrid_ItemDataBound event.
>
> HTH
>
> Elton WAng
>
>
> >-----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
> >.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Probelm with TemplateColumn and Checkbox ReskatoR ASP .Net 0 10-08-2008 02:38 PM
Help with CheckBox inside a TemplateColumn JasmineC ASP .Net Datagrid Control 2 09-02-2004 09:26 AM
TemplateColumn to display Checkbox in DataGrid Paul ASP .Net Datagrid Control 1 04-21-2004 04:13 AM
BUG in DataBind? After .DataBind there are more DataGrid Items than DataSet Rows! Michael ASP .Net Datagrid Control 0 12-29-2003 07:47 PM
TemplateColumn CheckBox Nus Pieds ASP .Net 0 07-16-2003 02:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57