1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by geniusvishal
0
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {
            GridView1.EditIndex = e.NewEditIndex;
            bindGvEdit();
        }
        catch (Exception ex)
        {
            lblUpdate.Text = ex.Message;
        }
    }

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row = GridView1.Rows[e.RowIndex];
        objCust.CustId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
        objCust.CustAddress = txtCustAddress.Text;
        objCust.UpdateNewUser();
        GridView1.EditIndex = -1;
        bindGvEdit();
    }


    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            ViewState["CustId"] = e.CommandArgument;
            objCust.CustId = Convert.ToInt32(e.CommandArgument);
            DataSet dsSelectNewUser = objCust.SelectNewUser();
            txtCustAddress.Text = dsSelectNewUser.Tables[0].Rows[0].ItemArray[2].ToString(); 
        }
    }

I am actually inserting the value of CustAddress into txtCustAddress.TextBox and then using this textbox value into my Gridview.. But to my knowledge i found out that CustAddress is not getting any value on Debbuging.. Plz help to rectify the problem...

0

Guys got the solution for this :
No need for including Row command... Only rowUpdating is enough....

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row = GridView1.Rows[e.RowIndex];
        objCust.CustId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
        objCust.CustAddress = ((TextBox)row.Cells[2].Controls[0]).Text;
        objCust.UpdateNewUser();
        GridView1.EditIndex = -1;
        bindGvEdit();
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.