我现在有一张表有一列int型字段.存放的是销售额 以万元为单位.
我现在要把这一列在GridView中显示的时候加上万比如表中存放的是100 显示在GV 中就是100万
用自带的修改更新 点击时 把100万又要显示成100 这个怎么弄?
我现在要把这一列在GridView中显示的时候加上万比如表中存放的是100 显示在GV 中就是100万
用自带的修改更新 点击时 把100万又要显示成100 这个怎么弄?
调试欢乐多
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="头部">
<ItemTemplate>
<asp:Label ID="Label1" Text='<%# string.Format("{0}万",(int)Container.DataItem) %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
init();
}
} private void init()
{
gv.DataSource = result();
gv.DataBind();
}
private System.Collections.Generic.List<int> result()
{
System.Collections.Generic.List<int> list = new System.Collections.Generic.List<int>();
list.Add(100);
list.Add(200);
return list;
}
Private Sub dgContent_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgContent.ItemDataBound
Dim dt As DateTime
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
If Not e.Item.DataItem Is Nothing Then
if bEdit then
e.Item.Cells(0).Text = e.Item.DataItem("money_field")
else
e.Item.Cells(0).Text = e.Item.DataItem("money_field") & "万"
end if
End If
End Select
End Sub可以参考一下,应该类似的。