GridView实现性别的显⽰前台:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" />
<asp:BoundField DataField="userid" HeaderText="编号" />
<asp:BoundField DataField="Name" HeaderText="⽤户名" />
<asp:TemplateField HeaderText="性别">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# ShowString((int)Eval("sex")) %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# ShowString((int)Eval("sex")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="price" HeaderText="价格" />
</Columns>
</asp:GridView>
后台:
public string ShowString(int str)
{gridview不显示
string strFont = string.Empty;
if (str == 1)
{
strFont = "男";
return strFont;
}
else if (str == 0)
{
strFont = "⼥";
return strFont;
}
else
{
strFont = "不详";
return strFont;
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论