473,320 Members | 2,104 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.

Check Box In A datagrid

hi friends,
i need code for deleting a particular row from a datagrid when i select the particular checkbox in the same datagrid.
Thanking You..
Mar 21 '07 #1
3 928
sani723
117 100+
you can find here

Check This

Or this

Click Here
Mar 21 '07 #2
hi,
check this example this will surely help u
http://aspalliance.com/articleViewer.aspx?aId=427&pId=-1
bye
all the best
Mar 21 '07 #3
hai,
i think this vl b helpful..
write this code in ur delete button......
try it out..

private void btnDelete_Click(object sender, System.EventArgs e)
{
int cId;
string id;
foreach (DataGridItem dg in datagrid.Items)
{
CheckBox deleteChkBxItem = (CheckBox)dg.Cells[0].FindControl("chkSelect");
if (deleteChkBxItem.Checked == true)
{
id= (((Label)dg.Cells[1].FindControl("ID")).Text);
cId=Convert.ToInt32(id.ToString());
SqlConnection conn;
conn =new SqlConnection("Data Source=xyz;Initial catalog=dbname;user id=sa");
conn.Open();
SqlCommand mycom=new SqlCommand("delete from table where Id=@ID ",conn);
mycom.CommandType=CommandType.StoredProcedure;
SqlParameter[] sqlparam=new SqlParameter[1];
sqlparam[0]=new SqlParameter("@ID",System.Data.SqlDbType.Int,4);
sqlparam[0].Value=cId;
mycom.Parameters.Add(sqlparam[0]);
mycom.ExecuteNonQuery();
conn.Close();
}
}
}
Mar 21 '07 #4

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

Similar topics

4
by: VR | last post by:
I am trying to embed a check box into a FlexGrid's cell, but having a problem when I start scrolling the grid. Here is my MyCheckBox class... class MyCheckBox : CheckBox { void Init (...
1
by: Neal | last post by:
HI all, I have an issue with check box in datagrid. I would like it to check and uncheck based on a database value of NULL or a Date Value. If there is a date value for that column then check...
7
by: Jaime Stuardo | last post by:
Hi all.. I have a DataGrid with checkboxes. In the header I have a "check all" checkbox. I'm wondering if there is an easy way to check all checkboxes using that checkbox. I could do it using...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
1
by: .NETn00b | last post by:
Is this possible? I need to create a multi-select DataGrid, and I cannot use CheckBoxes. I want the selected rows to appear highlighted. One possible work-around that occurred to me was to...
2
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
14
by: Brett Romero | last post by:
I'm using a DataGrid and have assigned this.DataSourceChanged += new EventHandler( DataGrid_DataSourceChanged ); This works fine but there is one case where it doesn't. How can I check if...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: Scott | last post by:
Hello all and thanks in advance for any help you may be able to offer me. I am quite new to asp.net and am trying to work with a datagrid but am having some problems with it. Here's the...
0
by: sumitdipsite2005 | last post by:
I am trying to use VB6 as a middleware between two 3rd party applications. "App. A" ----> VB6 ------> "App B" i am having no trouble sending data from VB to the "App B". But i am having...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.