Gatagrid与输出数据库内容的问题!求解! 例如我在数据库里将性别字段的值保存为1,0但是要在输出时输出男,女,并和Gatagrid绑定.请问需要怎么做啊?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在RowDataBoundprotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[2].Text.Trim() == "1") { e.Row.Cells[2].Text = "男"; } else if (e.Row.Cells[2].Text.Trim() == "0") { e.Row.Cells[2].Text = "女"; } } } 添加模版列,插入dropdownlist,可以通过判断用代码绑定,也可以直接在设计的时候将将数据绑定到dropdownlist 对性别使用模版列<asp:TemplateField> <ItemTemplate> <asp:Label ID="Sex" runat="server" Text='<%#Eval("BookId").ToString()=="1"?"男":"女"%>' /> </ItemTemplate></asp:TemplateField> 爬虫相关问题 下面的代码很是飘逸啊 不敢独享 .netURL传值 模擬50人同時訪問,CPU及内存的使用率怎麽取得? 按钮修改自定义控件的属性无效的问题? mssql union all 帮我优化下 百分求答 时间格式化一个月 C#读取的数据如何引用到javascript数组 请问访问.net网页时,错误代码是500 ,是哪里的问题呢? 问个小问题。。。。。 关于treeview的问题 C# void 与 bool转换
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[2].Text.Trim() == "1")
{
e.Row.Cells[2].Text = "男";
}
else if (e.Row.Cells[2].Text.Trim() == "0")
{
e.Row.Cells[2].Text = "女";
}
}
}
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Sex" runat="server" Text='<%#Eval("BookId").ToString()=="1"?"男":"女"%>' />
</ItemTemplate>
</asp:TemplateField>