Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

DataGrid Single row selection - ASP.NET

I have a datagrid in ASP.NET. I need to have only one row selected using a check box column. Created template column for checkbox but not able to have only one check box selected at any time. Need to uncheck if any row is already checked. Thanx.
0
amiteshsinha
Asked:
amiteshsinha
1 Solution
 
Howard BashSenior Software EngineerCommented:
I hate to skirt the question.  But,  radio buttons are for mutually exclusive list item selections, not checkboxes.  At least that always used to be the case.

I think you need to tie a piece of javascript to the checkbox event.  In your template build the call with a parameter such as the key for the row, and save that id as the "checked_row_id", perhaps as a session variable.  After this, the rendering of the checkbox (checked/unchecked) gets built from this session variable on the postback.

So, one routine might store the currently checked row by some uniqure value (ie. ID),  and then another routine which sets the checked/unchecked for each posted back row, based on comparing the row's ID with the saved ID.

Something like that anyway...
0
 
mrdilliardCommented:
This is kind of close to what you're looking for. Just don't build in the functionality to select all, and I think that's what you're looking for.

http://www.codeproject.com/aspnet/Multi-select_Dataagrid.asp
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now