hi Shubham ,
thank u for your advice i have another problem i.e i have stored into data base but not insert the grid view controls values it show as nulls or zero in table column fields
where is the problem i am not understanding i have spend lot of time but i am not gettting the solution
this is my code:
protected void btnSubmit_Click1(object sender, EventArgs e)
{
DataTable dt = (DataTable)gvClient.DataSource;
dt.Columns.Add("ddlClient", typeof(string));
dt.Columns.Add("txtSun", typeof(string));
dt.Columns.Add("txtMon", typeof(string));
dt.Columns.Add("txtTue", typeof(string));
dt.Columns.Add("txtWed", typeof(string));
dt.Columns.Add("txtThu", typeof(string));
dt.Columns.Add("txtFri", typeof(string));
dt.Columns.Add("txtSat", typeof(string));
dt.Columns.Add("txttot", typeof(string));
foreach (GridViewRow row in gvClient.Rows)
{
DropDownList ddlClient = (DropDownList)row.FindControl("ddlClient");
TextBox txtSun = (TextBox)row.FindControl("txtSun");
TextBox txtMon = (TextBox)row.FindControl("txtMon");
//TextBox txtMon = (TextBox)gvrow.FindControl("txtSun");
TextBox txtTue = (TextBox)row.FindControl("txtTue");
TextBox txtWed = (TextBox)row.FindControl("txtWed");
TextBox txtThu = (TextBox)row.FindControl("txtThu");
TextBox txtFri = (TextBox)row.FindControl("txtFri");
TextBox txtSat = (TextBox)row.FindControl("txtSat");
TextBox txttot = (TextBox)row.FindControl("txttot");
DataRow dr = dt.NewRow();
dr["ddlClient"] = row.Cells[0].Text;
dr["txtSun"] = row.Cells[1].Text;
dr["txtMon"] = row.Cells[2].Text;
dr["txtTue"] = row.Cells[3].Text;
dr["txtWed"] = row.Cells[4].Text;
dr["txtThu"] = row.Cells[5].Text;
dr["txtFri"] = row.Cells[6].Text;
dr["txtSat"] = row.Cells[7].Text;
dr["txttot"] = row.Cells[8].Text;
//dr["fuBill1"] = row.Cells[].Text;
dr["ddlStatus"] = row.Cells[9].Text;
cmd = new SqlCommand("TimeSheetApplication008", con);--->timeshhetappliaction(procedure name)
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@txtSun",SqlDbType.NVarChar).Value=txtSun.Text;
cmd.Parameters.AddWithValue("@txtMon", SqlDbType.NVarChar).Value = txtMon.Text;
cmd.Parameters.AddWithValue("@txtTue", SqlDbType.NVarChar).Value = txtTue.Text;
cmd.Parameters.AddWithValue("@txtWed", SqlDbType.NVarChar).Value = txtWed.Text;
cmd.Parameters.AddWithValue("@txtThu", SqlDbType.NVarChar).Value = txtThu.Text;
cmd.Parameters.AddWithValue("@txtFri", SqlDbType.NVarChar).Value = txtFri.Text;
cmd.Parameters.AddWithValue("@txtSat", SqlDbType.NVarChar).Value = txtSat.Text;
cmd.Parameters.AddWithValue("@txttot", SqlDbType.NVarChar).Value = txttot.Text;
cmd.Parameters.AddWithValue("@ddlStatus", SqlDbType.NVarChar).Value = ddlStatus.SelectedValue;
//cmd.Parameters.AddWithValue("@TextBox7", TextBox7.Text);
cmd.ExecuteNonQuery();
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('Records successfully saved!');", true);
}
}
THANKS,
RAMESH
qvg200286, if this helps please login to Mark As Answer. | Alert Moderator