Thursday, July 2, 2009

Asp.net datagrid Using template field det particular datakey

protected void gvleaveHistory_RowCommand(object sender, GridViewCommandEventArgs e)
{
string strLeaveId = e.CommandArgument.ToString();//gvleaveHistory.DataKeys[e.RowIndex]["LeaveId"].ToString().Trim();
if (strLeaveId != string.Empty)
{

Leave objLeave = new Leave();
objLeave.DeleteLeaveByLeaveId(Convert.ToInt32(strLeaveId));
LoadInitialDataForHistry();
LoadInitialData();
}
}


======ASPX Code============
<ItemTemplate >
<asp:LinkButton ID="lnkCancel" runat="server" OnClick="lnkCancel_Click" CommandArgument='<%# Eval("LeaveId")%>'> Cancel </asp:LinkButton >
</ItemTemplate >

No comments: