<asp:GridView ID="GridView3" runat="server" Width="782px" AutoGenerateColumns="False" DataKeyNames="Id" ShowFooter="true" OnDataBound="GridView3_DataBound">
<Columns>
<asp:TemplateField HeaderText="环境修正系数" SortExpression="ZonghehuanjingXishu">
<ItemTemplate>
<asp:Label ID="Label3ZonghehuanjingXishu" runat="server" Text='<%# Bind("ZonghehuanjingXishu") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>我想把<%# Bind("ZonghehuanjingXishu") %>取出的值乘以100再显示,不知道怎么实现.
<Columns>
<asp:TemplateField HeaderText="环境修正系数" SortExpression="ZonghehuanjingXishu">
<ItemTemplate>
<asp:Label ID="Label3ZonghehuanjingXishu" runat="server" Text='<%# Bind("ZonghehuanjingXishu") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>我想把<%# Bind("ZonghehuanjingXishu") %>取出的值乘以100再显示,不知道怎么实现.
解决方案 »
- html单选按钮问题
- 应用程序发生了无法处理的异常
- c# 中DataGridView删除问题
- get{},set{}传值的问题啊
- 高手帮忙:关于winform中三个窗体传值的问题。
- 申明变量或者引用对象加个?是什么意思
- ClickOne部署问题,下载 http://192.168.1.69/xxxx.application 未成功
- 如何用代碼給Windows服務加上描述???使之安裝以後在服務控制台裏可以看到該描述??
- 谁能给出一个BizTalk Server 2004 正式版的下载地址?
- 在vs.net beta2中为什么我引用不成System.Data.ADO和System.Net?请大虾帮帮忙
- 大家都来谈谈自己的编程经验吧!
- 如何让DataTable一列在gridview显示两列
<asp:GridView ID="GridView3" runat="server" Width="782px" AutoGenerateColumns="False" DataKeyNames="Id" ShowFooter="true" OnDataBound="GridView3_DataBound">
<Columns>
<asp:TemplateField HeaderText="环境修正系数" SortExpression="ZonghehuanjingXishu">
<ItemTemplate>
<%# Convert.ToInt32(Bind("ZonghehuanjingXishu")) * 100 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<%#Convert.ToInt32(Eval("ZonghehuanjingXishu").ToString()) * 100 %>
Convert.ToInt32(object)是错的
自己好好看看它有几个重载吧……
这里直接转换就行了,这里执行的是后台代码
例如:0.1200,只显示0.12
这样行的吧
<ItemTemplate>
<asp:Label ID="Label3ZonghehuanjingXishu" runat="server" Text=' <%# fun(DataBinder.Eval(Container.DataItem,"ZonghehuanjingXishu"))%>'> </asp:Label>
</ItemTemplate>
然后在cs代码里处理
protected string fun(object par)
{
string ret;
int Result=Convert.ToInt32(par);
return ret = (Result*100).Tostring();
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string value= DataBinder.Eval(e.Row.DataItem, "ZonghehuanjingXishu").ToString();
Label labValue = (Label)e.Row.FindControl("Label3ZonghehuanjingXishu");
labValue.Text=Convert.ToInt32(value)*100;
}
}