填充dropdownlist1的dropdownlist2 onSelectedIndexChange()事件

时间:2016-05-08 14:25:15

标签: c# asp.net

当我从 dropdownlist1 中选择相关的 Category_Items 时,我想在 dropdownlist2 中显示 Category_Type_Item 这是填充dropdownlist1的页面加载代码:

byte[] uriField = copy.getBytes(Charset.forName("UTF-8"));
byte[] payload = new byte[uriField.length + 1];
payload[0] = prefixByte;
System.arraycopy(uriField, 0, payload, 1, uriField.length);
NdefRecord rtdUriRecord = new NdefRecord(
        NdefRecord.TNF_WELL_KNOWN,
        NdefRecord.RTD_URI,
        new byte[0],
        payload);

这里是onselectedindexchange代码,用于填充dropdownlist2:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList2.DataTextField = "Select Item First";


            //dropdown for categories
            String query3 = "SELECT * from tbl_Category  ";
            SqlDataAdapter da3 = new SqlDataAdapter(query3, conn);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3);


            if (ds3.Tables[0].Rows.Count != 0)
            {

                DropDownList1.DataSource = ds3;
                DropDownList1.DataTextField = "Category_Name";
                DropDownList1.DataValueField = "Category_ID";
                DropDownList1.DataBind();

            }
            else
            {
                DropDownList1.DataTextField = "Values Not Found";
            }}

为什么这段代码不起作用,有人请帮帮我

0 个答案:

没有答案