前台代码:
<asp:TemplateField HeaderText="性别" SortExpression="Sex">
<EditItemTemplate>
<asp:DropDownList ID="ddlSex" runat="server" SelectedValue='<%# Eval("Sex") %>'>
<asp:ListItem Text="男">男</asp:ListItem>
<asp:ListItem Text="女">女</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Sex") %>'></asp:Label>
</ItemTemplate>后台代码:
DropDownList ddlSex = (DropDownList)dvUser.FindControl("ddlSex"); string Sex = ddlSex.SelectedItem.Text ;
<asp:TemplateField HeaderText="性别" SortExpression="Sex">
<EditItemTemplate>
<asp:DropDownList ID="ddlSex" runat="server" SelectedValue='<%# Eval("Sex") %>'>
<asp:ListItem Text="男">男</asp:ListItem>
<asp:ListItem Text="女">女</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Sex") %>'></asp:Label>
</ItemTemplate>后台代码:
DropDownList ddlSex = (DropDownList)dvUser.FindControl("ddlSex"); string Sex = ddlSex.SelectedItem.Text ;
解决方案 »
- System.Data.SqlClient.SqlException: 超时时间已到。在操作完成之前超时时间已过或服务器未响应。
- 哈哈,搞了一天终于成功了,帮小弟看下原理是这样的不?
- System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
- 如何获得刚刚插入的自增长的ID
- “System.EventArgs”并不包含对“NewPageIndex”的定义
- 数据库中有一个 <img> 标签 如何在页面中将 图片显示出来
- .net 中怎么样把一个类放到botton click事件当中!
- 执行存储过程的问题?郁闷了
- 高分求:CDO读取Exchange 2000中文件夹(folder)的代码
- 懂WMI的请进来看一下好吗?
- gridview怎么获取checkbox的值
- <A href >传值问题
绑定repeater或者gridview数据时,有没有在Page_Load里面加if(!IsPostBack)判断
<asp:ListItem >男 </asp:ListItem>
<asp:ListItem >女 </asp:ListItem>
</asp:DropDownList> 就可以
写成<asp:ListItem value="男">男 </asp:ListItem>
或者<asp:ListItem男 </asp:ListItem>