0

I have grid view in which there are image buttons, I want to access grid view data on button click event of that particular row but dont know how to get those values on button click event. Image button is inside template field of gridview.

2 Answers 2

2

You can get it in the RowCommand event of the gridview.

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].///
        ................
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

protected void grdList_RowEditing(object sender, GridViewEditEventArgs e)

{

    int test_reg_Id = Convert.ToInt32(grdList.DataKeys[e.NewEditIndex].Values[0]);
    string query = "select * from test_reg where Id=" + test_reg_Id + "";
    query += Session["test_reg_Id"].ToString();
    dtable = con.sqlSelect(query);
    txt_id.Text = dtable.Rows[0][0].ToString();
    txtuname.Text = dtable.Rows[0][1].ToString();
    txtpass.Text = dtable.Rows[0][2].ToString();
    ddlcountry.SelectedItem.Text = dtable.Rows[0][3].ToString();

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.