使用查询字符串设置下拉列表中的选择
全面披露:我对 .NET 非常陌生,并且对它有一定的感觉。被要求进行调整,但我不确定从哪里开始。希望有人能够提供有用的链接或示例。将不胜感激。
基本上,我想读取查询字符串......让我们称之为“inquirytype”。如果该查询字符串等于“其他”,我想更改 .ascx 控件中下拉框中的选择(见下文):
<asp:DropDownList ID="inquiry_type" runat="server" CssClass="inquiry_type">
<asp:ListItem Value="" Selected="True">Select Below</asp:ListItem>
<asp:ListItem>Place an Order</asp:ListItem>
<asp:ListItem>Order Status</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
有没有一种方法可以将此代码保留在我的 .ascx 文件中并仍然实现这是通过向我的 .cs 文件添加一些内容来实现的吗?或者我必须在 .cs 中创建一个函数来完全创建此下拉列表?
提前致谢!
Full disclosure: I'm very new to .NET and sort of feeling my way through it. Been asked to make a tweak and I'm not sure exactly where to start. Was hoping someone might be able to provide a helpful link or example. Would be greatly appreciated.
Basically, I'd like to read in a querystring... let's call it "inquirytype". If that querystring is equal to "other", I want to change the selection in a dropdown box that I have in my .ascx control (see below):
<asp:DropDownList ID="inquiry_type" runat="server" CssClass="inquiry_type">
<asp:ListItem Value="" Selected="True">Select Below</asp:ListItem>
<asp:ListItem>Place an Order</asp:ListItem>
<asp:ListItem>Order Status</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
Is there a way I can keep this code in my .ascx file and still achieve this by adding something to my .cs file? Or must I create a function in my .cs that creates this dropdown list altogether?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样的事情:
您也可以这样做:
我认为您不需要测试 null,但如果您这样做:
Try something like this:
You can also do it like this:
I don't think you'll need to test for null, but incase you do:
if (Drodownlist.Text == "")
{
if (Drodownlist.Text == "")
{