How to get DataGridView with vertical columns

In my application Winform C#, I have DataGridView, associated with DataTableand having many entries. I want to display the details of the selected row ( DataGridView) in the following format (see image). Why use Controlor (Trick).

enter image description here

In other words: "The first column of the table must have a column name, and the second column must have the corresponding values"

+4
source share
5 answers

, DataGridView, , . :

, , , , , , . :

  • .
  • , , . , booean , .
  • , , . , , .

, , PropertyGrid DataGridView. DataTable , , #/winforms: grid System.Data.DataRow

+3

,

  • , DataGridView , ( )
  • DataGridView ( )
  • SelectionChanged , dg.SelectedRows [0].Index, .
  • DataTable , . 1 , DataRow DataGridView, , 3.
  • , 2, datatable, 4, .
0
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
    <tr>
        <td>Reg_no</td>
        <td>
            <asp:Label runat="server" ID="lblreg_no" Text='<%# Eval("reg_no") %>' />
        </td>
    </tr>
    <tr>
        <td>Name</td>
        <td>
            <asp:Label runat="server" ID="lblname" Text='<%# Eval("name") %>' />
        </td>
    </tr>
    <tr>
        <td>DOB</td>
        <td>
            <asp:Label runat="server" ID="lbldob" Text='<%# Eval("dob") %>' />
        </td>
    </tr>
</ItemTemplate>
</asp:Repeater>

Then, in your code behind, you simply bind it like to another container.

Repeater1.datasource= "";
Repeater1.DataBind();
-1
source

Source: https://habr.com/ru/post/1523434/


All Articles