【问题标题】:sort and page result of data bind with eval by gridview数据的排序和页面结果通过gridview与eval绑定
【发布时间】:2013-08-05 07:54:59
【问题描述】:

大家好,我的问题是数据是从 sql 检索并显示在标签中,但是一旦我无法分隔所有数据中的数据行,所有数据都显示在一行中,请帮助

<asp:GridView ID="grid_advertise_2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                GridLines="None" OnPageIndexChanging="GridView2_PageIndexChanging" PageSize="1"
                ShowHeader="False" OnSelectedIndexChanged="GridView2_SelectedIndexChanged">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <tr>
                    <td id="advertise_2">
                        <asp:Label ID="lbl_advertise_2"
                                   runat="server"
                                   Font-Names="Tahoma"
                                   Font-Size="12pt"
                                   ForeColor="black"
                                   Text='<%# Bind("TitleEn") %>'/>
                    </td>
                 </tr>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

在服务器代码中

protected void Page_Load(object sender, EventArgs e)
{
    string Path = "Article.aspx";
    Session.Add("Path", Path.ToString());
    if (!IsPostBack)
    {
        this.BindGridadvertise1();
        this.BindGridadvertise2();
    }
}

private void BindGridadvertise1()
{
    myConnection c = new myConnection();
    SqlDataAdapter da = 
      new SqlDataAdapter("select * from TblArticleWishka where ID >= 0 ", c.Cnn);
    DataSet ds = new DataSet();
    da.Fill(ds);
    grid_advertise_1.DataSource = ds.Tables[0];
    grid_advertise_1.DataBind();
}

【问题讨论】:

    标签: c# gridview eval bind paging


    【解决方案1】:

    嗨,伙计们,我做到了,我通过创建新的销售并为他们提供 cssclass 来做到这一点 int j = 0;

    protected void grid_advertise_1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (j<=1)
       {
            myConnection c = new myConnection();
            SqlDataAdapter da = new SqlDataAdapter("select * from TblArticleWishka where ID>=0 ", c.Cnn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            int i = 1;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
    
                i++;
                TableCell a = new TableCell();
                a.CssClass = "advertise_1_" + i + "";
                a.Text = (string)dr["TitleEn"];
                e.Row.Cells.Add(a);
                a.DataBind();
            }
            j++;
       }
    }`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 2013-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多