By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

Bind checkbox in Datagrid

P: n/a
Hi,

I have managed to create a Datagrid with a template column with checkboxes
following Q306227. The dataset i have bound to the datagrid contains 1
column that allows NULL value and I would like to bind the checkbox to be
checked if this value is anything else than DBNULL. I have used to designer
to create the grid and dataset etc, and from what I understand I need to
edit the databinding property of the checkbox in the template to evaluate
the Checked property, but I have not managed to figure out how to create an
expression that evaluates if a coulmn is empty or not.

Any hint would be appreciated

Regards

Niclas
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Niclas,

If your checkbox is built inside the .aspx file, you can check the checkbox
for all non-null values like this:

<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Currency Value">
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server" Checked='<%# not
isDBnull(DataBinder.Eval(Container, "DataItem.CurrencyValue"))
%>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

The same thing in the code behind would be like this:

oCheckBox.Checked = Not IsDBNull(container.DataItem("CurrencyValue"))

Is that what you meant?

Ken
MVP [ASP.NET]
"MS Newsgroups" <no****@nospam.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have managed to create a Datagrid with a template column with checkboxes
following Q306227. The dataset i have bound to the datagrid contains 1
column that allows NULL value and I would like to bind the checkbox to be
checked if this value is anything else than DBNULL. I have used to
designer
to create the grid and dataset etc, and from what I understand I need to
edit the databinding property of the checkbox in the template to evaluate
the Checked property, but I have not managed to figure out how to create
an
expression that evaluates if a coulmn is empty or not.

Any hint would be appreciated

Regards

Niclas


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.