例如有以下datagrid控件:<asp:datagrid id=MyDataGrid runat="server" AutoGenerateColumns="False" BorderColor="#660033">
<Columns>
<asp:BoundColumn DataField="phn" HeaderText="手机号"></asp:BoundColumn>
<asp:BoundColumn DataField="area" HeaderText="地区"></asp:BoundColumn>
<asp:BoundColumn DataField="type" HeaderText="卡类型"></asp:BoundColumn>
</Columns>
</asp:datagrid>其中:type(卡类型)这一列在数据库中是tinyint类型(具体表示:1、全球通  2、动感地带  3、神州行)我希望在页面中显示卡类型的内容不是“1、2、3”之类的数字,而是具体的名称“全球通、动感地带、神州行”;在datagrid控件中应该怎么实现?

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=F73EF6AD-6878-4748-B963-5181252E5AED
      

  2.   

    可以在itemdatabound事件里手工处理
      

  3.   

    在SQL語句就可以實現
    Select type=case type when 1 then '全球通'
                      when 2 then '动感地带'
                      when 3 then '神州行'
                      else '' end
    from table_Name
      

  4.   

    谢谢各位的支持,itemdatabound事件里手工处理怎么做,有没有代码?