protected void Grid_DealersC_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Sel") { DetailState.Value = "edit"; string str = e.CommandArgument.ToString(); string[] Lstr = str.Split(','); int index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; ScriptManager.RegisterStartupScript(Page, GetType(), "function", "<script>edit('" + index + "','" + Lstr[0] + "');</script>", false); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closepup", "$('#modal-normal').modal('show');", true); } if (e.CommandName == "Del") { detailtype.Value = "true"; int indexid = Convert.ToInt16(e.CommandArgument.ToString()); DataTable dt = new DataTable(); dt = (DataTable)ViewState["Detail"]; dt.Rows.RemoveAt(indexid); ViewState["Detail"] = dt; Grid_DealersC.DataSource = dt; Grid_DealersC.DataBind(); } }
protected void Detail(string id) { SqlConnection Conn = new SqlConnection(); Conn.ConnectionString = ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString; DataTable dt = new DataTable(); try { string CmdString = @""; CmdString = @"select * from DealersC where R_no=@R_no "; SqlCommand cmd = new SqlCommand(CmdString, Conn); cmd.Parameters.AddWithValue("R_no", id); Conn.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); dt.Load(dr); ViewState["Detail"] = dt; Grid_DealersC.DataSource = dt; Grid_DealersC.DataBind(); } catch (Exception ex) { DB_string.log("Dealers_edit:", ex.ToString()); } finally { Conn.Close(); } }
protected void Enter_Click(object sender, EventArgs e) { string state = DetailState.Value; DataTable dt = new DataTable(); dt = (DataTable)ViewState["Detail"]; if (state == "ins") { detailtype.Value = "true"; DataRow dr = dt.NewRow(); dr["Country"] = Country_detail.Value; dt.Rows.Add(dr); ViewState["Detail"] = dt; Grid_DealersC.DataSource = dt; Grid_DealersC.DataBind(); } else { detailtype.Value = "true"; int indexid = 0; indexid = Convert.ToInt32(index_detail.Value); //dt.Rows[indexid]["R_no"] = id.Value; //dt.Rows[indexid]["C_no"] = C_no_detail.Value; dt.Rows[indexid]["Country"] = Country_detail.Value; Grid_DealersC.DataSource = dt; Grid_DealersC.DataBind(); } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closepup", "$('#modal-normal').modal('hide');", true); }