跪求各位老大!帮忙解决一下这个DropDownList问题吧!我数据库是这样的我在pubs数据库里建了一个表!
表名为table
字段id int 4
mflag char(1)页面上
<asp:DropDownList id="txtDD" runat="server">
<asp:ListItem Value="0">更新</asp:ListItem>
<asp:ListItem Value="1">未更新</asp:ListItem>
</asp:DropDownList>
就是这样的!我数据库里mflag这个字段就存了0和1这两个数值!我就想数据库里是0!DropDownList显示更新!
数据库里是1!DropDownList显示为更新!哪位大哥给我写一个全的!在Page_Load!能显示就好啦!!谢谢各位!帮小弟续写一下吧!
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn=new SqlConnection("server=losthost;user id=sa;database=pubs");
请续写!谢谢啦!!
C#语言啊!}
表名为table
字段id int 4
mflag char(1)页面上
<asp:DropDownList id="txtDD" runat="server">
<asp:ListItem Value="0">更新</asp:ListItem>
<asp:ListItem Value="1">未更新</asp:ListItem>
</asp:DropDownList>
就是这样的!我数据库里mflag这个字段就存了0和1这两个数值!我就想数据库里是0!DropDownList显示更新!
数据库里是1!DropDownList显示为更新!哪位大哥给我写一个全的!在Page_Load!能显示就好啦!!谢谢各位!帮小弟续写一下吧!
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn=new SqlConnection("server=losthost;user id=sa;database=pubs");
请续写!谢谢啦!!
C#语言啊!}
SqlConnection conn=new SqlConnection("server=losthost;user id=sa;pwd=sa;database=pubs");
string strSQL="select id,mflag from table";
SqlDataAdapter mycom=new SqlDataAdapter(strSQL,myConn);
mycom.Fill(ds,"datatabale");
DropDownList.DataValueField=ds.Tables["datatable"].Columns[0].ColumnName;
DropDownList.DataTextField=ds.Tables["datatable"].Columns[1].ColumnName;
DropDownList.DataBind();