locked
Manipulating the Gridview withh Access Database.. RRS feed

  • Question

  • User-811640212 posted

    I am Beginner of asp.net, having problems with my work.. (Please Help genius)

    I am working on a small project of  "E Store" using Access Database..

    Here i want to retrieve saved adds from database to Gridview and i done, but not like i want... the gridview displays data from top to bottom (One add in a row).

    But i want 3 adds in a row. so that the gridview display data from right to left..

    Please Help me..

      OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + Server.MapPath("~\\App_Data\\Products.mdb"));
    
            con.Open();
    
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandText = "select * from Shirts";
    
            cmd.Connection = con;
    
            OleDbDataAdapter Adaptor = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            Adaptor.Fill(ds);
    
            GridView1.DataSource = ds;
            GridView1.DataBind();
    
            con.Close();

    Saturday, November 15, 2014 8:08 AM

Answers

  • User-1716253493 posted

    I guess you can try ListView control

    <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" GroupItemCount="3">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 15, 2014 10:57 AM
  • User61956409 posted

    Hi IMRAN,

    Thanks for your post.

    You could use datalist to display multiple rows horizontally as below.

    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            Name:
        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    
    DataList1.RepeatColumns = 3;
    DataList1.RepeatDirection = RepeatDirection.Horizontal;
    

    For more information about “How to: Specify Horizontal or Vertical Layout in DataList”, you could refer to the following link.

    Hope it will be helpful to you.

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 17, 2014 3:11 AM

All replies

  • User-1716253493 posted

    I guess you can try ListView control

    <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" GroupItemCount="3">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 15, 2014 10:57 AM
  • User61956409 posted

    Hi IMRAN,

    Thanks for your post.

    You could use datalist to display multiple rows horizontally as below.

    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            Name:
        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    
    DataList1.RepeatColumns = 3;
    DataList1.RepeatDirection = RepeatDirection.Horizontal;
    

    For more information about “How to: Specify Horizontal or Vertical Layout in DataList”, you could refer to the following link.

    Hope it will be helpful to you.

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 17, 2014 3:11 AM