Click here to Skip to main content
15,902,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a gridview and I have bind data in gridview and now 100 data inside the gridview. There is a checkboc control I have added inside gridview by taking itemtemplate.So when I click the check box of header then all the check box will be selected or indivisuall I can select .

So Suppose I have selected 20 row out of hundred, Now i want to put the 20 records in a DataTable Which I have selected.

How Can I get the details of the 20 record from gridview.



Thanks...
Posted
Comments
Aniket Yadav 25-Feb-12 5:16am    
have you looked at the links which is posted.

C#
DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn();
checkboxColumn.Width = 30;
checkboxColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
list.Columns.Insert(0, checkboxColumn);
 
// add checkbox header
Rectangle rect = list.GetCellDisplayRectangle(0, -1, true);
// set checkbox header to center of header cell. +1 pixel to position correctly.
rect.X = rect.Location.X + (rect.Width / 4);
 
CheckBox checkboxHeader = new CheckBox();
checkboxHeader.Name = "checkboxHeader";
checkboxHeader.Size = new Size(18, 18);
checkboxHeader.Location = rect.Location;
checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged);
 
list.Controls.Add(checkboxHeader);
 
Share this answer
 
Comments
Michel [mjbohn] 25-Feb-12 5:40am    
added code tags

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900