473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

multiple checkboxes in a single column of gridview

hello everyone,

i have a gridview in which i have multiple checkboxes in a single column.
means for every row in the gridview i have four checkboxes in one column e.g Add, Delete, Print, Modify.

now i need to bind these check boxes from database table according to the four different fields in the table in which the value is 0 and 1. if the column value is 1 than the checkbox should be displayed checked otherwise no.

i dont know how to handle such problem..
Apr 19 '08 #1
3 2728
DrBunchman
979 Expert 512MB
Hi santoshjsh,

To achieve this you can use the OnItemDataBound event of the datagrid to fire a function which will alter the properties of the controls inside your grid. The following example assumes you have a checkbox (chkAdd) and a label (lblAdd) inside your grid.

Expand|Select|Wrap|Line Numbers
  1. If E.Item.ItemType = ListItemType.Item Or E.Item.ItemType = ListItemType.AlternatingItem Then
  2. Dim lblAdd As Label = E.Item.FindControl("lblAdd") 
  3. Dim chkAdd As Checkbox = E.Item.FindControl("chkAdd")
  4.  
  5. If lblAdd.Text = "1" Then chkAdd.Checked = True
  6. End If
  7.  
Let me know how you get on,

Dr B
Apr 22 '08 #2
Thanx Mr. DrBunchman for your response.

and sorry for my late reply.
i did it in some otherway.
first i edited the template and inserted a column in which i put 4 checkboxes. and then using Bind() from the designer view i bound that column with datasource.



Hi santoshjsh,

To achieve this you can use the OnItemDataBound event of the datagrid to fire a function which will alter the properties of the controls inside your grid. The following example assumes you have a checkbox (chkAdd) and a label (lblAdd) inside your grid.

Expand|Select|Wrap|Line Numbers
  1. If E.Item.ItemType = ListItemType.Item Or E.Item.ItemType = ListItemType.AlternatingItem Then
  2. Dim lblAdd As Label = E.Item.FindControl("lblAdd") 
  3. Dim chkAdd As Checkbox = E.Item.FindControl("chkAdd")
  4.  
  5. If lblAdd.Text = "1" Then chkAdd.Checked = True
  6. End If
  7.  
Let me know how you get on,

Dr B
Apr 28 '08 #3
DrBunchman
979 Expert 512MB
Good stuff, I'm glad you got it sorted out.
Apr 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Faybert | last post by:
Hello, and Thanks in advance for any light you might shed on my troubles. I'm trying to setup a series of checkboxes, or a checkboxlist to control the results that are shown on a gridview...
6
by: Terry | last post by:
Good morning! How do I determine which SELECT button was clicked in a GridView? The multiple SELECT buttons will be used for an application approval process. Thank you in advance for your...
2
by: Anonieko | last post by:
Hello ASPNET guru's, What is a clean way to go around the problem of displaying a GridView templated column where data can contain Single Quote ( ' )? I maybe too naive, but this is of course...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
0
by: H5N1 | last post by:
Hi there It seems I've spotted interesting problem in a job I've got to do. I have 3 tables: meals, employees, and intersecting table: meals_for_employees with bool field meaning, that given...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
1
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
1
by: yumbelie | last post by:
Hi, I want to set multiple datafields from a dataset to a single boundcolumn in my gridview, but I can't see any easy way to do this since the DataField property of the boundcolumn takes a single...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.