Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 20th, 2004, 03:36 PM
Registered User
Join Date: Aug 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to display checkbox in a DataGrid


Another beginer's question :

I am still working on my very first form using ASp.NET and C# - so please bear with me.

I am fetching results into a DataGrid. One of the column has a Y or N value and I want show a Checkbox ( Checked if 'Y' and non-checked, if 'N'). I also need to change background color of the row, if the value is 'N'. Here is my ItemTemplate :
<asp:BoundColumn DataField="ACTIVE_IND" ItemStyle-HorizontalAlign="Center" HeaderText="Active Indicator"></asp:BoundColumn>
Data for this DataGrid is bound in the click event of a submit button.

DataGrid1.DataSource = ds.Tables["nnld"];
Thanks in advance.

Reply With Quote
  #2 (permalink)  
Old August 23rd, 2004, 09:47 AM
Friend of Wrox
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post

its not a beginer's question.!
I think you should have a checkbox somewhere like ItemTemplate and also you
fill your grid with your datasource,well
for getting what is bound to your filed you should work with
and also for changing the backcolor,you can work with yourDataGridItem.CssClass
and also you should have a <STYLE></STYLE> tag in your aspx file and set the CssClass
with one of the styles declared in your <STYLE> tag.
but where you can work with them?surely somewhere like DataGrid1_ItemDataBound
have a look at this example...
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item ||
    e.Item.ItemType == ListItemType.AlternatingItem ||
    e.Item.ItemType == ListItemType.SelectedItem ||
    e.Item.ItemType == ListItemType.EditItem)
this example marks every item that aSpecialValue has been bound to it also change it's
CSS changes according to YourNewCssDecalredInStyleTag.

Reply With Quote
  #3 (permalink)  
Old August 23rd, 2004, 03:35 PM
Registered User
Join Date: Aug 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you. Let me try your suggestion.


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display checkbox inside Table like structure in Vb remya1000 General .NET 0 May 15th, 2008 03:59 PM
checkbox in datagrid asad_prog VB.NET 0 November 25th, 2006 02:41 PM
Display every checkbox checked InsouciantCoquette Classic ASP Components 0 February 10th, 2006 04:02 AM
Checkbox in the datagrid sadermine VB Components 0 August 16th, 2005 10:36 PM
Display Checkbox if checked or not jmss66 Classic ASP Basics 6 January 23rd, 2004 11:19 AM

All times are GMT -4. The time now is 06:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.