首页 > 开发 > 综合 > 正文

DataBinding dropDownList

2024-07-21 02:16:47
字体:
来源:转载
供稿:网友

最大的网站源码资源下载站,

<html>
<head>

    <script language="c#" runat="server">

        void page_load(object sender, eventargs e) {

            if (!page.ispostback) {

               arraylist values = new arraylist();

               values.add ("in");
               values.add ("ks");
               values.add ("md");
               values.add ("mi");
               values.add ("or");
               values.add ("tn");

               dropdown1.datasource = values;
               dropdown1.databind();
            }
        }

        void submitbtn_click(object sender, eventargs e) {
           label1.text = "you chose: " + dropdown1.selecteditem.text;
        }

    </script>

</head>
<body>

    <h3><font face="verdana">databinding dropdownlist</font></h3>

    <form runat=server>
    
        <asp:dropdownlist id="dropdown1" runat="server" />

        <asp:button text="submit" onclick="submitbtn_click" runat=server/>

        <p>
        
        <asp:label id=label1 font-name="verdana" font-size="10pt" runat="server" />

    </form>

</body>
</html>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表