//client side
GridLines="none" CellPadding="5" PageSize="15" AllowPaging="true">
//server side
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
myConn.Open();
SqlCommand cmd = myConn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "tblResumeUploadABind";
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
sda.Fill(dt);
ViewState["resume"] = dt;
gvResumeManage.DataSource = dt;
gvResumeManage.DataBind();
}
}
protected void OnRowCommand(object sender, GridViewCommandEventArgs e)
{
DataTable dtt = (DataTable)ViewState["resume"];
if (e.CommandName == "delete")
{
GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
int RowIndex = row.RowIndex;
int id = Convert.ToInt32(e.CommandArgument);
if (ViewState["resume"] != null)
{
myConn.Open();
SqlCommand cmd = myConn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "tblResumeUploadADelete";
cmd.Parameters.Add(new SqlParameter("@id", Convert.ToString(id)));
cmd.ExecuteNonQuery();
myConn.Close();
dtt = (DataTable)ViewState["resume"];
dtt.Rows.Remove(dtt.Rows[RowIndex]);
gvResumeManage.DataSource = dtt;
gvResumeManage.DataBind();
ViewState["resume"] = dtt;
}
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanwar RanwaPosted Sep 8, 2018, 5:35 AM