<asp:gridview id="GridView1" runat="server" allowpaging="True" xmlns:asp="#unknown">
AutoGenerateColumns="False"
DataSourceID="cmmentsdatasource" Width="992px" onrowcommand="rowcmd"
DataKeyNames='id' CellPadding="0" CssClass="style51" ForeColor="#333333">
<rowstyle backcolor="#EFF3FB" font-bold="False" height="20px"></rowstyle>
<columns>
<asp:templatefield>
<itemtemplate>
<asp:linkbutton id="lb1" runat="server" causesvalidation="false" onclientclick="return confirm('Are You sure to delete this entry')" text="Delete" commandargument="<%#Eval("id")%>"></asp:linkbutton>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="id" headertext="ID" sortexpression="id" />
<asp:boundfield datafield="senderid" headertext="SenderId">
SortExpression="senderid" />
<asp:boundfield datafield="sendername" headertext="SenderName">
SortExpression="sendername" />
<asp:boundfield datafield="comments" headertext="Comments">
SortExpression="comments" />
<asp:boundfield datafield="date" headertext="Date" sortexpression="date" />
</asp:boundfield></asp:boundfield></asp:boundfield></columns>
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
</footerstyle>
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
</pagerstyle>
<selectedrowstyle backcolor="#D1DDF1" font-bold="True" forecolor="#333333">
</selectedrowstyle>
<headerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
Font-Size="Small" Height="20px">
</headerstyle>
<editrowstyle backcolor="#2461BF"></editrowstyle>
<alternatingrowstyle backcolor="White"></alternatingrowstyle>
</asp:gridview>
on row command event
protected void rowcmd(object sender, GridViewCommandEventArgs e)
{
try
{
Int32 id = Convert.ToInt32(e.CommandArgument);
string comm = "Delete from tblComments where id=@id";
SqlCommand cmd = new SqlCommand(comm, Db.GetConnection());
cmd.Parameters.AddWithValue("id", id);
cmd.ExecuteNonQuery();
GridView1.DataBind();
}
catch (Exception ex)
{
}
}
O