本文介绍了如何解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在数据绑定后显示在下拉列表中选择一个项目



这里我的代码是


hi

am trying to display select an item in dropdownlist after databind

Here My code is

DataTable DropDT = new DataTable();
   string Qry = "select tax from maodeladd where modelname='" + drop2.SelectedItem.Text"'";
            DropDT = cbbal.GetData(Qry);
            string StrTax = DropDT.Rows[0]["tax"].ToString();
            drop3.DataSource = cbbal.DSet("select tax,id from Tax");
            drop3.DataTextField = "tax";
            drop3.DataValueField = "id";
            drop3.DataBind();
            drop3.Items.Insert(0, new ListItem("Non", "0"));
            drop3.Items.FindByValue(StrTax.Trim().ToString()).Selected = true;





但是我在此代码中获得null异常



谢谢!



But am getting null exceptions in this code

Thank You !

推荐答案


这篇关于如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 02:10
查看更多