Click here to Skip to main content
15,912,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi! All,
I have a dropdown on my aspx page and based on the dropdown value i have to show the number of rows in a gridview, effeciently using sessions & viewstates.
for example:
If I select 4 in dropdown, then it should display only 4 rows in the gridview.

Thanks
Posted
Comments
Sandeep Mewara 4-Mar-11 10:19am    
Ok. Good to know. So, where do you got stuck?

Share what you have done and the issue to look at.

well there are two ways to handle this.
1. When ever selection is chnaged, run your db query and return only the number of selection, say only 4. This is the most easiest to handle and less work on the UI side.

2. If you don't want to handle in the db, then in the RowCreated event monitor how many rows are created then made the remaining rows visible property to false.

I believe the first approach is the best one and easier and less maintenance.
 
Share this answer
 
try this one it will be work


at design side autopostback="true" to your Dropdown
on your drop-down selected index change at coding side
{
Gridview.PageSize = Convert.ToInt32(Dropdown.SelectedItem.Text);
Put your grid view bind data code
}
 
Share this answer
 
v2

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