在Gridview中为下拉列表加载一次数据 [英] Loading data once for dropdownlist in Gridview

查看:119
本文介绍了在Gridview中为下拉列表加载一次数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有Gridview数据并在Gridview中放置了一个下拉列表框。

此下拉列表框值已加载来自DB。

Eg - 价值观是:

ABC

XYZ

123



但是如果我的Gridview有100行,那么每次为每个下拉列表框加载数据库。

值必须在页面时加载一次加载。

我计划将值存储在Temp表和数组中,然后使用该变量填充下拉列表框。



你能指导我这个或给我一个更好的解决方案。

Dear Friends,

I have Gridview with data and placed a dropdownlist box in the Gridview.
This dropdownlist box value is loaded from DB.
Eg - Values are :
ABC
XYZ
123

But if my Gridview is having a 100 rows then each time its loading the DB for each dropdownlist box.
Values has to be loaded only once at the time of page load.
I am planing to store the values in Temp table and array, then use the variable for the filling the dropdownlist box.

Can you people guide me on this or give me a better solution.

推荐答案

嗨Arun,



我想在这里建议的是,是的,你可以。

你可以尝试另一种绑定列表的方式来下拉这样的



1)从DB获取下拉列表中的值并将其分配给列表

2)现在获取gridview的值并绑定i t。

3)加载所有下拉列表后,为其分配一个类。

4)现在按类将列表值分配给gridview中的每个下拉列表。



希望这会对你有所帮助。



问候,

RK
Hi Arun,

What I would like to suggest here is, Yes you can.
You can try another way to bind list to drop down like this

1) Get values from DB for dropdownlist and assign it to a list
2) Now get values for gridview and bind it.
3) Once all dropdown list is loaded assign a class to it.
4) Now by class assign list value to each and every dropdownlist in the gridview.

Hope this helps you a bit.

Regards,
RK



试试吧:

Hi Try it:
if (!IsPostBack) {
                    //Bind your grid view and ddl
    }



Yours Farhad。


Yours Farhad.


使用数组从数据库中获取值,然后将此arrray分配给gridview
use array to fetch the value from database and then this arrray assign to gridview


这篇关于在Gridview中为下拉列表加载一次数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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