I have datagridview in my program I have to create table at run time and also give primary and foreign key at run time.
please tell me methods to do this.I have taken four cell(variable name(textbox),data type(combobox),primary key(checkbox),foreign key(checkbox)).When click check box of foreign key display message("select").
How to perform this.
Display message when only one checkbox check from 2 in datagridview
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 20, 2010, 3:18 AM EDT
In your grid view add template column and add the CheckBox control from toolbox.
Bind the grid.
set the grid properties like this:
Now add the code for GridView1_RowDataBound event like below:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox c = (CheckBox)e.Row.FindControl("CheckBox1");
Label l = (Label)e.Row.FindControl("Label1");
c.Attributes["onClick"] = "if(" + c.ClientID + ".checked==true){alert('you have selected " + l.Text + "')}";
}
}
Download the attach project. Change the connection string and change the other template fields and enjoy the coding.
Please mark as answer if it helps you.