<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再显示,不知道怎么实现.

解决方案 »

  1.   


    <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>
      

  2.   

     <%#Convert.ToInt32(Bind("ZonghehuanjingXishu").ToString()) * 100 %>
     <%#Convert.ToInt32(Eval("ZonghehuanjingXishu").ToString()) * 100 %>
      

  3.   

    ??,不行吗,不行就是RP问题了Convert.ToInt32(string)
    Convert.ToInt32(object)是错的
      

  4.   

    谁告诉你Conver.ToInt32(object)是错的?
    自己好好看看它有几个重载吧……
      

  5.   

    在页面里实现这么辛苦,倒不如在SQL中实现简便快捷。
      

  6.   

    <%# Bind("ZonghehuanjingXishu") %>
    这里直接转换就行了,这里执行的是后台代码
      

  7.   

    如何不显示<%# Bind("ZonghehuanjingXishu") %>后两位:
    例如:0.1200,只显示0.12
      

  8.   

    <%# Convert.ToDouble(Bind("ZonghehuanjingXishu")).ToString("N2") %>
      

  9.   

    <%# Convert.ToInt32(Bind("ZonghehuanjingXishu")) * 100 %>
    这样行的吧
      

  10.   

    在gridview的itemdatabind事件里处理就行了  另外也可以用
    <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();
                     }
      

  11.   

    <%# Convert.ToInt32(Bind("ZonghehuanjingXishu")) * 100 %>如果不存在数据类型转换问题,这句是绝对可以的。
      

  12.   

    在RowDataBound事件里做吧 
      

  13.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            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;         
            }
        }