Hi,
I am getting error while handling with gridview. i.e.., i write edit and delete operation on Rowcommand,it is working well,after that i write a code for paging ,for paging code see below .when u click on edit button its working well,but when u click on paging i am getting these errors
Unable to cast object of type 'System.Web.UI.WebControls.GridView' to type 'System.Web.UI.WebControls.LinkButton'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.GridView' to type 'System.Web.UI.WebControls.LinkButton'.
Source Error:
Line 137: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
Line 138: {
Line 139: GridViewRow grow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
Line 140: Label ITCategoryId = (Label)GridView1.Rows[grow.RowIndex].FindControl("ITCategoryId");
Line 141:
code protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow grow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
Label ITCategoryId = (Label)GridView1.Rows[grow.RowIndex].FindControl("ITCategoryId");
if (e.CommandName == "Edit")
{
Response.Redirect("ClassifieldsCategory.aspx?Category_id=" + ITCategoryId.Text);
}
}
Paging Code protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
FillGrid();
}
Can u please help me
Thanks InAdvance
T.Madhuri