不好意思,写错一个字:是静态值,不是“表态值”。
我是这样做的:(page_load里有它的绑定数据)
<asp:dropdownlist
id = "asearch"
runat = "server">
<asp:ListItem >sfsfd</asp:listItem>
</asp:dropdownlist>但这样不行,怎么回事?
我是这样做的:(page_load里有它的绑定数据)
<asp:dropdownlist
id = "asearch"
runat = "server">
<asp:ListItem >sfsfd</asp:listItem>
</asp:dropdownlist>但这样不行,怎么回事?
解决方案 »
- 大家说说阿里巴巴企业网站首页怎么做的!!!
- 统计在线人数
- 为什么招的都是PHP,ASP.NET的去哪了??
- 要求点击gridview的删除弹出确定代码????
- 自己在做个人BlOG !现在想自写个音乐播放器,可以循环播放的那种!没有思路!大家给点意见
- 关于用户权限存入Session和Cookies?
- 下面的代码中,为什么加了一个文件夹目录就显示不了图片了,就路径错误了,要怎么写才可以正常显示,请帮忙
- 文件上传问题?
- datagrid使用右键问题
- 输出1到100000之间的数字,不足五位前面补"0",例如:00001,请问如何实现?
- 怎样对“datagrid”进行增加,修改删除呢?
- 如何在一个目录下查找所有含“test" 的 .asp,.php,.htm 文件
{
string connstring="data source=mbm;initial catalog=kmsdb;user id=mbm;password=mbm";
string querystring="select distinct cDepartmentname from t_Department";
SqlConnection myconn=new SqlConnection(connstring);
myconn.Open();
SqlDataAdapter myadapter=new SqlDataAdapter(querystring,myconn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"t_Department");
myconn.Close();
DropDownList1.DataSource=ds.Tables[0].DefaultView;
DropDownList1.DataTextField=ds.Tables["t_Department"].Columns["cDepartmentName"].ToString();
DropDownList1.DataBind();DropDownList1.Items.Insert(0,"%");//静态的,这行以上是从数据库表绑定的
}
你是怎样强加一个表态值的?请教!
谢谢!
0是索引值,表示插入到最顶
然后在
DropDownList1.Items[0].Selected=true;//默认选择第一行
那怎样设置它的Value呢?
若要两者不一样呢?
{
string connstring="data source=mbm;initial catalog=kmsdb;user id=mbm;password=mbm";
string querystring="select distinct cDepartmentname from t_Department";
SqlConnection myconn=new SqlConnection(connstring);
myconn.Open();
SqlDataAdapter myadapter=new SqlDataAdapter(querystring,myconn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"t_Department");
myconn.Close();
DropDownList1.DataSource=ds.Tables[0].DefaultView;
DropDownList1.DataTextField=ds.Tables["t_Department"].Columns["cDepartmentName"].ToString();
DropDownList1.DataBind();DropDownList1.Items.Insert(0,"%");//静态的,这行以上是从数据库表绑定的DropDownList1.Items[0].Value="111";//赋值给value,现在Text属性是%,而value属性是111,明白了就给点分吧
}
DropDownList1.Items(0).Value="111" ‘用小括号
一束“鲜花”送给mbm(-- (@ \/ @) --) ∞ ∞ ∞ Ω Ω
∞∞∞ ∞ ∞ ΩΩΩΩΩΩΩΩΩΩΩ
∞ ∞ ∞∞∞∞∞∞ Ω Ω
∞∞∞∞∞ ∞
∞ ∞ ∞ ∞ Ω Ω
∞∞∞∞∞ ∞∞∞∞∞ Ω Ω Ω
∞ ∞ ∞ ∞ ΩΩ Ω Ω
∞∞∞∞∞∞∞∞∞∞∞ Ω Ω ΩΩ
∞ Ω ΩΩΩ Ω
∞∞∞ ∞ Ω Ω Ω
∞∞ ∞ Ω ΩΩΩΩΩ