locked
How to get Column Names from List<> RRS feed

  • Question

  • Hi,

      I used LINQ in wcf to return data in List. In XAML im getting result in e.Reult. Here I want to get Column names in string.

    When I type e.Result[0].    then I got list column in front of dot. How can I egt names in string in for loop from e.result.

     

    Thanks ,

    Mahendra

    Wednesday, November 26, 2008 5:18 AM

Answers

  •  Hi Mahendra,

    You can try to use the column's head to get the dataGrid's columns' name.

    try to refer the below code:

                this.theDataGrid.ItemsSource = e.Result;

                string str = "";
                for (int i = 0; i < this.theDataGrid.Columns.Count; i++)
                {
                    str += this.theDataGrid.ColumnsIdea.Header.ToString() + ";";
                }

                HtmlPage.Window.Alert(str);

    Saturday, November 29, 2008 2:11 AM

All replies

  • Hi Mahendra,

    Can you specify u r problem in more detail?

    Wednesday, November 26, 2008 6:13 AM
  • Hi Hitesh,

         In my application I wamt to show chart period vs Quantity. Period are column names and quantity is value of that column. Here im using LINQ.From Linq i can fet e.Result[0].ColumnName.Value . by this can get value against column. I can show values as quantity.But cant get column names in for loop.

    So how to do that.

    Thanks,

    Mahendra

    Wednesday, November 26, 2008 6:23 AM
  • Hi,

    I am not sure but have you tried e.Result[0].ColumnName[0] .Tostring() ?

    Wednesday, November 26, 2008 6:26 AM
  • yes I tried with this but not getting columnname property as u mentioned.

     

    Thanks,

    Mahendra

    Thursday, November 27, 2008 4:14 AM
  •  Hi Mahendra,

    You can try to use the column's head to get the dataGrid's columns' name.

    try to refer the below code:

                this.theDataGrid.ItemsSource = e.Result;

                string str = "";
                for (int i = 0; i < this.theDataGrid.Columns.Count; i++)
                {
                    str += this.theDataGrid.ColumnsIdea.Header.ToString() + ";";
                }

                HtmlPage.Window.Alert(str);

    Saturday, November 29, 2008 2:11 AM