Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:09:44+00:00 2026-06-16T07:09:44+00:00

I have a table displayed from a database. I would like to display the

  • 0

I have a table displayed from a database.
I would like to display the horizontal Header Column-> Vertically

My table Structure is

  Server|Role|Status|Date

but I would like to display as

  Server
  Role
  Status
  Date

I tried the to flip the dataset, and tried to build it. Initially the build was successful but I can’t view any data on my datagrid.
kindly help , is there any other way to approach this problem ?

here is my code snippet

SqlConnection con;
SqlDataAdapter da = null;
DataSet ds = null;

private void Page_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
       da = new SqlDataAdapter("Select * from [ServerDB_Test].[dbo].[ServerStatus] ", con);
       ds = new DataSet();
       foreach (DataTable dt in my_DataSet.Tables)
       {
            DataTable table = new DataTable();

            for (int i = 0; i <= dt.Rows.Count; i++)
            {
                table.Columns.Add(Convert.ToString(i));  }
                DataRow r;
                for (int k = 0; k < dt.Columns.Count; k++)
                { 
                    r = table.NewRow();
                    r[0] = dt.Columns[k].ToString();
                    for (int j = 1; j <= dt.Rows.Count; j++)
                    {  
                        r[j] = dt.Rows[j - 1][k]; 
                    }
                    table.Rows.Add(r);
                }
            ds.Tables.Add(table);
        }
        da.Fill(ds);
        dataGrid1.ItemsSource = ds.Tables[1].DefaultView;
   }
   catch (Exception ex)
   {
       Console.WriteLine(ex.Message);
   }
}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:09:45+00:00Added an answer on June 16, 2026 at 7:09 am

    At first I tried rotating my Table in my DB using Pivot table, but couldn’t succeed..

    then I found to set the datagrid.layouttransform and a datagrid.Cellstyle for rotating the view of the table.

             <DataGrid.LayoutTransform>
                 <TransformGroup>
                     <RotateTransform Angle="90"/>
                      <MatrixTransform Matrix="-1,0,0,1,0,0"/>
                  </TransformGroup>
               </DataGrid.LayoutTransform>
                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="-90"/>
                                    <ScaleTransform ScaleX="1" ScaleY="-1" />
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.ColumnHeaderStyle>
               <DataGrid.CellStyle>
                    <Style  TargetType="DataGridCell">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="-90"/>
                                    <ScaleTransform ScaleX="1" ScaleY="-1" />
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.CellStyle>
    

    and set the height and width of the columns accordingly and it works fine.
    Thanks !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create table which can display data from database into JSF
I would like to display data from a database onto a content page using
I'm trying to load data from database and display it in table like here:
i have a table that display a record from the database. Using this php
I have a table from which I query data to display resultset using stored
I have created one jTable. I want to display the data into table from
I have a table which is currently displayed like this: Question OptionType What is
I have the following table structure inside a view which gets displayed in the
I have a database with a table for CD releases. One column is a
I am trying to display information from database. I have set $config['per_page'] to 2,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.