根据下拉列表中的选择将Bindingdata转换成表格 [英] Bindingdata into Table according to selection in the dropdowns

查看:147
本文介绍了根据下拉列表中的选择将Bindingdata转换成表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio 2010和SQL管理Studio,我创建了一个页面,管理员可以通过该页面获得学生结果的详细信息。



我有7个下拉菜单


  1. 学校

  2. 年份

  3. 课程

  4. 版本

  5. 教师


  6. 学习单元

学校和年份是必填字段。



我提供了一个名为Excel的按钮在页面的底部,点击它将根据选择进行的网格视图转储到Excel中。



现在我已经完成了每个下拉列表选择的索引更改事件我绑定其他下拉列表和gridview。



如果管理员以较低的顺序选择任何其他下拉列表,则会根据更改的选择重新加载表。 >

因此,某些选择需要很多加载时间。



是否可以使按钮单击事件中的代码喜欢 点击它将首先检查管理员选择哪个下拉列表,并根据唯一选择的下拉菜单值,我可以使gridview并将其转储到Excel中。

  string s1 =; 
string s2 =;
if(dropdown1.SelectedIndex> -1)
s2 = dropdown1.Text.Trim();
else
s2 =;
if(dropdown2.SelectedIndex> -1)
s1 = dropdown2.Text.Trim();
else
s1 =;

根据此字符串,您可以编写查询以从db获取数据,并可将该数据绑定到gridview 。


Using Visual Studio 2010 and SQL management Studio, I have created a page by which admin can get detail of student' result.

I have 7 drop downs in it.

  1. School
  2. Year
  3. Lesson
  4. Version
  5. Teacher
  6. Domain
  7. Learning Unit.

School and year is mandatory fields.

I have provided a button named Excel at the bottom of the page on clicking on which It dump the grid view made based on the selection into Excel.

right now I have done is on every dropdowns selected index change event I am binding the other dropdowns and also the gridview.

If the admin select any other dropdown in lower order it will reload the table according the changed selection.

So it takes a lot ot loading time for some selection.

Is It possible to make the code in button click event like on clicking on that it will first check which dropdowns are selected by admin and based on the only selected drop downs' value I can make the gridview and dump it into Excel.

解决方案

Inside the button click event write like,

        string s1 = "";
        string s2 = "";
        if (dropdown1.SelectedIndex > -1)
           s2 = dropdown1.Text.Trim();
        else
           s2 = "";
        if (dropdown2.SelectedIndex > -1)
            s1 = dropdown2.Text.Trim();
        else
            s1 = "";

based on this strings you can write query to get data from db and can bind this data to your gridview.

这篇关于根据下拉列表中的选择将Bindingdata转换成表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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