Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hi i am retrieving data from database into dataset which acts as a datasource for my gridview. Now i am getting this error "grid view fired event PageIndexChanging which wasn't handled" how to rectify this error and why i am getting it . i am giving my code here. please suggest me steps tp modify my steps so as to remove this error
my gridview name is gdshow.
here is my code

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
                   SqlConnection conn = new SqlConnection(str);
                   SqlCommand cmd = new SqlCommand("spshow",conn);
                   cmd.CommandType = CommandType.StoredProcedure;
                   cmd.Parameters.AddWithValue("@var", ddlshow.SelectedValue);
                   SqlDataAdapter adp = new SqlDataAdapter(cmd);
                   DataSet ds = new DataSet();
                   adp.Fill(ds);

                   try
                   {
                       conn.Open();
                       gdshow.Visible = true;
                       gdshow.DataSource = ds;
                       gdshow.DataBind();
                   }

                   catch (Exception E)
                   {
                       Response.Write(E.Message);

                   }
                   finally
                   {
                       conn.Close();

                   }
}



*Fixed pre tag
Posted
Updated 14-Feb-12 17:41pm
v2
Comments
_Maxxx_ 14-Feb-12 23:44pm    
According to the docco[^], this event is only raised when one of the pager buttons is clicked...

Dear Friend,

The solution to your problem lies in this link:-

http://www.jigsawboys.com/2008/10/22/the-gridview-fired-event-pageindexchanging-which-wasnt-handled/[^]

Don't forget to mark this as your answer if it helps you out.

Thanks
 
Share this answer
 
Hii allow paging functionallity in your griedview.May be the number of records in the ds is more than the default records in gried.either increase the pagesize of griedview or embed it with paging functionallity.Hope it helps you...!!
 
Share this answer
 
There is only one solution to this problem..

Your problem is that you have not handled PageIndexChanging event of your gridview.. Just write an event handler for your gridview.. It will 100% work..

steps for writing the event:

1) select your grid view.
2) go to properties window of that grid view
3) select the PageIndexChanging event and double click on the event

write the code to handle the gridview paging(if required) ..
If you need the paging coding for grid view just contact me..

try it.. Accept the answer if you like it..
All the best.. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900