如何根据下拉列表和文本框显示数据并查看按钮单击 [英] How to display data based on dropdownlist and textbox and view button clicks

查看:51
本文介绍了如何根据下拉列表和文本框显示数据并查看按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts!



我想根据下拉列表选择和文本框中的密码输入显示Gridview中的数据。

<我的网页上有
我有下拉列表(部门),文本框(密码)和查看按钮。



当我从下拉列表中选择部门时在文本框中输入密码,然后单击查看按钮。



部门是



Hello Experts !

Just i want to display the data from Gridview based on dropdownlist selection and password entry in textbox.

on my webpage i have dropdownlist(Department),, textbox(Password) and a View button.

When i select dept from dropdownlist and enter password in textbox and then click view button.

Departments are

<asp:DropDownList ID="DDLDepartmentInventory" runat="server" Width="170px"

                                        AutoPostBack="True"

                                        onselectedindexchanged="DDLDepartment_SelectedIndexChanged"

                                        Height="23px" CssClass="text_form_fields_ddl_view">
  <asp:ListItem>---- Select Department ----</asp:ListItem>
   <asp:ListItem>KKIT</asp:ListItem>
   <asp:ListItem>KKFC</asp:ListItem>
    <asp:ListItem>KKJC</asp:ListItem>
     <asp:ListItem>KKMC</asp:ListItem>
      <asp:ListItem>KKMS</asp:ListItem>
  <asp:ListItem>KKTD</asp:ListItem>
    <asp:ListItem></asp:ListItem>
  </asp:DropDownList>





密码将基于部门。





它必须根据下拉列表显示gridview中的记录...直到那时gridview不能显示。



当页面加载时它不会show gridview。



请帮忙谢谢。



Password will based on Department.


it must show the records in gridview based on dropdownlist...till then gridview must not be displayed.

When page loads it doesnt show gridview.

Please help thanks.

推荐答案

你好,



这应该可以帮到你:



Hi,

This should get you started:

protected void ddl_OnSelectedIndexChanged()
{
string x=DDLDepartmentInventory.SelectedItem.Value;
string y=txtBoxPassword.Text;
DataTable dt=PopulateGrid(x,y);
gridview1.DataSource=dt;
gridview1.DataBind();
}

public DataTable PopulateGrid(string a, string b )
{
SqlDataAdapter da=new SqlDataAdapter("select * fron dbo.Table where Column1='"+a+"' and Column2='"+b+''",connectionString);
DataTable dt=new DataTable();
da.Fill(dt);
return dt;
}





在下拉列表的OnSelectedIndexChanged事件中,我们尝试使用2个参数绑定gridview,一个是ddl的选定项,而第二个是在文本框中输入的密码。代码的重复是不言自明的。看看并尝试一下。 />


-Re gards

Anurag



On OnSelectedIndexChanged event of the dropdownlist, we are trying to bind the gridview using 2 parameters, one is the selected item of the ddl, while the second is the password entered in the textbox.Rest of the code is self-explanatory. Have a look and try it.

-Regards
Anurag


这篇关于如何根据下拉列表和文本框显示数据并查看按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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