gridview的绑定表aaa后。某一列的值可能是0,1,2。他们对应的汉语是:检索,数据,存储。

来源:百度知道 编辑:UC知道 时间:2024/07/01 14:12:12
我绑定后这一列的值。不想显示数字。想显示汉字。
我的代码<asp:TemplateField HeaderText="服务器类型">
<EditItemTemplate>
<asp:DropDownList ID="dplIsOK" runat="server" SelectedValue=' <%# Eval("server_type") %>'>
<asp:ListItem Value="0">检索服务器</asp:ListItem>
<asp:ListItem Value="1">数据服务器</asp:ListItem>
<asp:ListItem Value="2">存储服务器</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_server_type" runat="server" Text=' <%# Bind("server_type") %>

先在.aspx.cs里定义个parmReplace函数
public static string ParmReplace(int col1)
{
string bbb="";
switch(col1)
{
case 0:
bbb="检索";break;
case 1:
...
}
return bbb;
}

-------------
<EditItemTemplate>
<asp:DropDownList ID="dplIsOK" runat="server" SelectedValue=' <%# Eval("server_type") %>'>
<asp:ListItem Value="0">检索服务器</asp:ListItem>
<asp:ListItem Value="1">数据服务器</asp:ListItem>
<asp:ListItem Value="2">存储服务器</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_server_type" runat="server" Text=' <%# ParmReplace(int.Parse(Bind("server_type").ToString()) %>'></asp:Label>
</ItemTemplate>
</asp:Tem