473,770 Members | 4,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bind checkbox in Datagrid

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
1 8350
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:TemplateCo lumn HeaderText="Cur rency Value">
<ItemTemplate >
<asp:CheckBox id="CheckBox1" runat="server" Checked='<%# not
isDBnull(DataBi nder.Eval(Conta iner, "DataItem.Curre ncyValue"))
%>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>

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

oCheckBox.Check ed = Not IsDBNull(contai ner.DataItem("C urrencyValue"))

Is that what you meant?

Ken
MVP [ASP.NET]
"MS Newsgroups" <no****@nospam. com> wrote in message
news:O3******** ******@TK2MSFTN GP10.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2159
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with these selected fields and allow user to click one or more CheckBox controls to activate this bit on the database table for a required ID. I have already added a template column to the DataGrid and I can get the
1
4498
by: Stephen | last post by:
I have the following asp:checkbox as a row in my datagrid. and im trying to write code on the onCheckedChanged event of it. The code im trying to write is incorrect as im getting build errors. What im trying to do is populate a label on my aspx page with the contents of the row in the database which I have checked. When I uncheck the checkbox I want the label to be set to blank so as it can be populated again when another checkbox in the...
2
3155
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
0
1857
by: mehul | last post by:
CheckBox template always evaluate to False even if checked in a DataGrid hosted inside a TabStrip in ASP.NET Hi, I am trying to develop an ASP.NET application. I am using TabStrip (which is part of IE WebControls). Inside a tab I have a datagrid defined as follows:
7
2277
by: Lars Netzel | last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true I can catch OnChange event on checkbox but how do I then catch what DataGridItemIndex is? Can I use some Event in the Datagrid that will fire off when the Checkbox is changed? regards /Lars
2
3051
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to post but doesn't seem to haven't any affect. It doesn't appear to call the UpdateMailSubscribers method.
4
2646
by: Nu2ASP.NET | last post by:
I have the following code in my code behind page: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI;
9
1595
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained. I know there is a lot of article on datagrid with checkbox but nothing helped me . Can anyone help me how to proceed ? Thanks
3
3150
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method expects a DataGridColumn so I instantiated an object of type TemplateColumn that I had hoped I could add a CheckBox to. I soon discovered that the ItemTemplate property of the TemplateColumn class returned an object that had implemented the...
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.