save data in database
i have a gridview in ASP.net which have two columns. in every row of that gridview first colmn contain some parent_user name which is stored already in database table and second column contain another gridvew. in second gridview first column contain checkbox and second column contain attribute of parent_user and othher 2 or three column contain dropdownlist. for selected attribute of parent_user which is done by click on checkbox i want to save the entire row of second gridview with the parent_user name into database table. The database is SQL Server. How can I do that?
karthick kumarPosted Oct 6, 2010, 7:51 AM
try this code on performin save...
here gridParent is the parent grid and gridChild is the ChildGrid within the parentgrid
GridView gridChild= gridParent.SelectedRow.FindControl("gridChild");
for (int j = 1; j <= gridChild.Rows.Count - 1; j++)
{
CheckBox chk = gridChild.Rows[j].FindControl("chkBox");
if (chk.Checked)
{
///Code for save...
}
}
--If my answer helped u any way. mark it is answered.
Gomathi PalaniswamyPosted Oct 6, 2010, 4:25 AM
Hi friend,
get the value like
System.Web.UI.WebControls.CheckBox t = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[0].Cells[0].FindControl("textb");