我的.ascx文件中有这个代码(我的search.aspx和search.aspx.cs文件中使用了ascx文件):
<form name="search" method="get" action="searchresults.aspx" id="searchform" runat="server">
<p>Need to refine your search? Use the fields below to narrow results.</p><br />
<input type="text" id="keywordSearch" value="Keyword" />
<div class="advanceSearchBox">
<p><b>Narrow results by:</b></p>
<asp:Literal ID="ltrlExplorePopulation" runat="server" />
<asp:Literal ID="ltrlExploreDatasource" runat="server" />
</div>
<img src="images/go_up.png" alt="GO" name="keywordSearchGO" width="34" height="24" id="keywordSearchGO" />
</form>
我的search.aspx.cs页面中的查询字符串中有数据,我想将其放入上面表单的输入中。并且第一个文字ltrlExplorePopulation被转换为:
<div class="narrowRes">Poulation</div><select class="narrowResSelect" name="population"><option value="0">All populations</option><option vale="1">Small population</option></select>
那么如何将查询字符串数据转换为此表单?
我的search.aspx.cs Page_Load有这个:
string keywords = Request.QueryString["keywords"];
string datasources = Request.QueryString["datasources"];
string population = Request.QueryString["population"];
我希望将关键字设置到上面的输入中,将people设置为select语句等。我不确定是否使用Form.Controls。?是对的吗?
答案 0 :(得分:0)
选项中的值是否为“所有人口”和“小人口”是动态的还是静态的?
使用静态你可以这样做:
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="All Population" Value="0"></asp:ListItem>
<asp:ListItem Text="Small Population" Value="1"></asp:ListItem>
</asp:DropDownList>
在代码隐藏中设置值,例如 DropDownList1.SelectedValue =群体; //这来自你的查询字符串。
请澄清我是否误解了你的问题。