I copied most of the part from msdn. Clicking on update does nothing

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)Session["hospital"];

            GridViewRow row = GridView1.Rows[e.RowIndex];//getting current index
            dt.Rows[row.DataItemIndex]["NAME"] = ((TextBox)(row.Cells[0].Controls[0])).Text;
            dt.Rows[row.DataItemIndex]["phone_no."] = ((TextBox)(row.Cells[1].Controls[0])).Text;
            dt.Rows[row.DataItemIndex]["ADDRESS"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
            dt.Rows[row.DataItemIndex]["HOS_ID"] = ((TextBox)(row.Cells[3].Controls[0])).Text;
            GridView1.EditIndex = -1;
            gvbind(GridView1, "select * from HOSPITAL"); //
}
catch(OracleException ex)
        {
            lblresult.Text = ex.Message.ToString();
        }
        catch (NullReferenceException nx)
        {
            lblresult.Text = nx.Message.ToString();
        }
    }

HERE IS THE asp.NET code< do i need to add edittemplate and itemtemplate to use this >

    <asp:GridView ID="GridView1" runat="server" DataKeyNames="HOS_ID" AutoGenerateColumns="False" OnRowDeleting="GridView1_RowDeleting" OnPageIndexChanging="GridView1_PageIndexChanging" 
OnRowUpdating="GridView1_RowUpdating" OnRowEditing="GridView1_RowEditing"
OnRowCancelingEdit="GridView1_RowCancelingEdit">
<Columns>
<asp:BoundField DataField="NAME" HeaderText="name" />
<asp:BoundField DataField="phone_no." HeaderText="Phone_no." />
<asp:BoundField DataField="ADDRESS" HeaderText="address" />
<asp:BoundField DataField="HOS_ID" HeaderText="hos_id"/>
<asp:CommandField ShowEditButton="true" />
<asp:CommandField ShowDeleteButton="true" />
</Columns>
</asp:GridView>

Related posts

Recent Viewed