zoukankan      html  css  js  c++  java
  • DataBinder的应用

    以前做东西时只知道DataBinder能在html中应用于datagrid或者datalist中的模板列,没想到在cs代码中也能用。

    以后再判断gridview列值时,就不用索引了,直接可以用字段名,

    cs代码中:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            int i = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "job_id"));
            if (i % 2 > 0)
            {
                e.Row.BackColor = System.Drawing.Color.Gray;
            }
        }

    html代码中:

    <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
                <Columns >
                    <asp:TemplateField >
                    <ItemTemplate >
                        <%#DataBinder.Eval(Container.DataItem,"job_id") %>
                     </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

  • 相关阅读:
    openVolumeMesh example 程序学习
    使用字符串创建java 对象
    HDU-1501-Zipper
    UVA-10285-Longest Run on a Snowboard
    HDU-2182-Frog
    HDU-2044-一只小蜜蜂
    POJ-1163-The Triangle
    HDU-1159-Common Subsequence
    HDU-2069-Coin Change
    HDU-4864-Task
  • 原文地址:https://www.cnblogs.com/wenming205/p/1266570.html
Copyright © 2011-2022 走看看