菜鸟为工作求助
要求是这样的:2个dropDownlist和一个texbox,一个按钮,一个gridview
选择第一个dropDownlist比如区域,然后第二个dropDownlist就根据第一个显示可选择的选项比如说区域内的省份,再在textbox里搜索比如说城镇,点击按钮,把结果显示在gridview
我用datasource做的,但总找不到思路
希望个位高手能给一个例子,不胜感激!
环境为vs2005 c#和sql2005
要求是这样的:2个dropDownlist和一个texbox,一个按钮,一个gridview
选择第一个dropDownlist比如区域,然后第二个dropDownlist就根据第一个显示可选择的选项比如说区域内的省份,再在textbox里搜索比如说城镇,点击按钮,把结果显示在gridview
我用datasource做的,但总找不到思路
希望个位高手能给一个例子,不胜感激!
环境为vs2005 c#和sql2005
这个方式应该能够满足你的要求,但是要装个asp.net ajax组件
参考
http://www.cnblogs.com/battler/archive/2005/07/06/97862.html
http://www.cnblogs.com/sunyong/archive/2006/08/16/478323.aspx
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>xx查询</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div align="center">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testcon %>"
SelectCommand="select distinct fgs from docddw"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:testcon %>"
SelectCommand="select distinct sf from docddw where fgs=@sf ">
<SelectParameters>
<asp:ControlParameter ControlID="fgs" Name="sf" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"></asp:SqlDataSource>
<br />
<table width="800" border="0">
<tr>
<th scope="col" style="height: 24px">选择分公司 :</th>
<th scope="col" style="height: 24px"><asp:DropDownList ID="fgs" runat="server" OnSelectedIndexChanged="fgs_SelectedIndexChanged" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="fgs" DataValueField="fgs">
<asp:ListItem Value="000">--请选择--</asp:ListItem>
</asp:DropDownList>
</th>
<th scope="col" style="height: 24px">选择省份:</th>
<th scope="col" style="height: 24px">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
Style="position: relative">
</asp:DropDownList></th>
</tr>
<tr>
<th scope="row">输入要查询的xx:</th>
<td colspan="3"><asp:TextBox ID="name" runat="server" /></td>
</tr>
<tr>
<th colspan="4" scope="row"><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="查询" /></th>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row" colspan="4"> <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" CellPadding="4" ForeColor="#333333" GridLines="None" Height="391px" Width="741px" AutoGenerateColumns="False">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView></th>
</tr>
</table>
</div>
<div align="center"><br />
</div>
</div>
</form>
</body>
</html>
还有,上面的代码我在配置数据源时测试能成功,但一运行这个页面就会在第二个DDL里面出现system.data.row之类的,而没有绑定的数据