How to position columns in select list based on a variable.
Posted
by Rohit
on Stack Overflow
See other posts from Stack Overflow
or by Rohit
Published on 2010-04-20T14:41:56Z
Indexed on
2010/04/20
14:43 UTC
Read the original article
Hit count: 232
c#
|sql-server-2005
I am creating a dynamic grid which is created by selecting the format defined in the below XML.My select list includes all columns in this XML,I want to position these columns columns on the basic of position attribute in XML.
<gridFormat>
<column property="CustomerID" dbName="CustName" HeaderText="Customer" IsVisible="0" Position="1" />
<column property="CustomerName" dbName="FacilityName" HeaderText="Facility" IsVisible="1" Position="3" />
<column property="FacilityInternalID" dbName="Pname" HeaderText="Patient" IsVisible="1" Position="2" />
</gridFormat>
I cannot select them in the order specified by the position attribute. I can do it in C# by looping around the returned datatable and specifically position columns using datatable.columns.setordinal() method. Is there any better way in SQL or C# to accomplish this.
© Stack Overflow or respective owner