How to call control inside GridView
How to call control inside GridView without in GridView1_RowDeleting or SelectedIndexChanged or row command but call in user defined function to selected row for update or delete .
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.
Najim MullaPosted Mar 4, 2015, 4:40 AM
Manish Kumar ChoudharyPosted Mar 4, 2015, 4:33 AM
Try This
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
e.CommandArgument // Return Primary key
GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
row.Cells[0].///
row.Cells[1].///
................
}
}
Najim MullaPosted Mar 4, 2015, 4:28 AM
Manish Kumar ChoudharyPosted Mar 4, 2015, 3:18 AM
Don't use session use like
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int empId = Convert.ToInt32(grdEmp.DataKeys[e.RowIndex].Value);
MyFuncation(empId);
GridView1.DataBind();
//Call any function that can perform delete operation based on value
}
private void MyFuncation(int Id)
{
//write your code here
}
Najim MullaPosted Mar 4, 2015, 3:00 AM
Manish Kumar ChoudharyPosted Mar 4, 2015, 2:44 AM
//Third way
Najim MullaPosted Mar 4, 2015, 2:39 AM
Manish Kumar ChoudharyPosted Mar 4, 2015, 2:37 AM
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
MyFuncation();
SqlCommand cmd = new SqlCommand("Delete From userTable (userName,age,birthPLace)");
GridView1.DataBind();
//Call any function that can perform delete operation based on value
}
private void MyFuncation()
{
//write your code here
}