<asp:GridView ID="grdLocation" runat="server" AutoGenerateColumns="False" DataKeyNames="LocationID" OnRowCancelingEdit="grdLocation_RowCancelingEdit" OnRowDeleting="grdLocation_RowDeleting" OnRowEditing="grdLocation_RowEditing" OnRowUpdating="grdLocation_RowUpdating" Visible="False" onrowdatabound="grdLocation_RowDataBound1"> <columns> <asp:BoundField DataField="LocationID" HeaderText="Category ID" Visible="False" /> <asp:BoundField DataField="LocationName" HeaderText="Category Name" /> <asp:CommandField HeaderText="Edit-Update" ShowEditButton="True" /> <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" /> </columns>
public void bindgrdLocation() { grdLocation.DataSource = (new Locations()).GetAllLocations(); grdLocation.DataBind(); if (grdLocation.Rows.Count > 0) { grdLocation.Visible = true; lblMessage.Visible = false; } else { grdLocation.Visible = false; lblMessage.Visible = true; lblMessage.Text = "No records Found"; } } protected void grdLocation_RowDeleting(object sender, GridViewDeleteEventArgs e) { Locations location = new Locations(); location.LocationID = Convert.ToInt32(grdLocation.DataKeys[e.RowIndex].Value.ToString()); location.Delete(); bindgrdLocation(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)