动态网格视图 [英] Dynamic Grid view

查看:74
本文介绍了动态网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

混淆了如何创建动态Grid View,以便在组合框中选择项目,它将在Grid View中显示其记录

很简单,有一个窗口有两件事,一个是组合框,包含表的名称,例如userTb和CustomerTb
另一个是数据网格视图...现在,如果我选择userTB,它将在网格视图中显示userTb,而当我选择CustomerTb时,它将在网格视图中显示客户记录...

Confused how to create dynamic Grid View such that in combo box i select the item it''ll show its records in Grid View

simple is that there is a window have two things one is combo box contains the name of tables e.g userTb and CustomerTb
and other one is data grid view ... now if i select userTB it''ll show userTb in grid view and when i select CustomerTb it''ll show customer records in grid view...

推荐答案

gridview可以使用数据源进行绑定.

gridview can be binded using a datasource.

gridview1.DataSource = methodToRetrievefromDB(DropDownTableName.SelectedValue);
gridview1.DataBind();


methodToRetrievefromDB(string TableName)中,您将必须对Table进行检查,以从所选表中检索记录并执行所选表的过程.

更改下拉列表的值时,您每次必须检索记录.您可以将两个表都存储在一个临时空间中,如果要避免一次又一次地访问数据库,请使用该表,但这取决于记录和表的数量.


In methodToRetrievefromDB(string TableName) you''ll have to apply checks for Table to retrieve records from and execute the procedure for the selected table.

On change of value of drop down you must retrieve records each time. You can store both tables in a temporary space and use that if you want to avoid hitting DB again and again but it depends on the number of records and tables.


这篇关于动态网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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