locked
datagrid with columns that have different rows of a datatable RRS feed

  • Question

  • User-1903746618 posted

    i want to make a datagrid with 2 columns and many rows
    the columns i want to have databinding with a datatable
    i want the 1 row 1 column of datagrid have data from 1 row of datatable
    i want the 1 row 2 column of datagrid have data from 2 row of datatable
    i want the 2 row 1 column of datagrid have data from 3 row of datatable
    i want the 2 row 2 column of datagrid have data from 4 row of datatable
    ......
    ......

    i use something like this

    <Columns>
        <asp:TemplateColumn  >
             <ItemTemplate    >
                 <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# databinder.eval(container.dataitem,"url") %>'Text='<%# databinder.eval(container.dataitem,"titlos") %>'></asp:HyperLink>
     </ItemTemplate  >
    </asp:TemplateColumn  >
    <Columns>

    <Columns>
        <asp:TemplateColumn  >
             <ItemTemplate    >
                 <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# databinder.eval(container.dataitem,"url") %>'Text='<%# databinder.eval(container.dataitem,"titlos") %>'></asp:HyperLink>
     </ItemTemplate  >
    </asp:TemplateColumn  >
    <Columns>

    but i have two times the same in tha datagrid left and right


    can anyone help me??

    Tuesday, February 9, 2010 10:55 AM

Answers

  • User-952121411 posted

    Databinding is not going to work as you described it.  Once the DataTable is bound to the grid each row in the DataTable will represent a single row in the DataGrid it was bound to.  One way you can get the data from each column into its own row in the DataGrid, is by going back to the source of the data population of the DataTable (probably a SQL statement) and modify your query to return the data in the format you want it displayed; 1 row for each record.

    How you see the results from the database, is how you are going to view the results of the bound columns in the DataGrid (aside from custom column formatting, etc.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 9, 2010 11:33 AM

All replies

  • User-952121411 posted

    Databinding is not going to work as you described it.  Once the DataTable is bound to the grid each row in the DataTable will represent a single row in the DataGrid it was bound to.  One way you can get the data from each column into its own row in the DataGrid, is by going back to the source of the data population of the DataTable (probably a SQL statement) and modify your query to return the data in the format you want it displayed; 1 row for each record.

    How you see the results from the database, is how you are going to view the results of the bound columns in the DataGrid (aside from custom column formatting, etc.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 9, 2010 11:33 AM
  • User-1903746618 posted

    thank you i have done it with your way 

    Wednesday, February 10, 2010 9:29 AM