基于下拉值显示gridview行的数量? [英] Based on dropdown value displaying number of gridview rows?

查看:69
本文介绍了基于下拉值显示gridview行的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!全部,

我的aspx页面上有一个下拉列表,根据下拉值,我必须在gridview中显示行数,有效地使用会话和视图状态。

例如:

如果我在下拉列表中选择4,那么它应该在gridview中只显示4行。



谢谢

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

推荐答案

有两种方法可以解决这个问题。

1.当选择被选中时,运行你的数据库查询并只返回选择的数量,只说4.这是最容易处理的,而且在UI方面工作较少。



2.如果你不想处理数据库,那么在 RowCreated 事件中监视创建了多少行,然后将剩余行的visible属性设置为false。



I相信第一种方法是最好的方法,更简单,更少维护。
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.


尝试这个方法它将是工作



opostback =true到您的下拉菜单

您下拉列表选择的索引更改编码方

{

Gridview.PageSize =转换。 ToInt32(Dropdown.SelectedItem.Text);

把您的网格视图绑定数据代码

}
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
}


这篇关于基于下拉值显示gridview行的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆