Hi,
I'm new to CSLA. I am binding my Gridview with a CSLA object. The AutogenerateColumns of GridView is set to true. The columns generated in the gridview are in a different order than the ones specified in my stored proc query.
For e.g. the query might be "select fname,lname,address,phone from employee " .
But the columns generated in the gridview will be in a different sequence (e.g. address,fname,lname,phone). How can I get the same sequence as specified in the query ?
--mcdev
We are using CSLADataSource
Here is the code:
//====Container Aspx page ====
<MyUserControl:MyGrid ID="GC" runat="server" /> //user control containing GridView
//set the DataSourceId="GridDataSource" of the GridVidew in above user control on Page_load
<csla:CslaDataSource ID="GridDataSource" runat="server"
TypeName="ProjLib.ProjList, ProjLib" EnableViewState="false" OnSelectObject="GridDataSource_SelectObject" OnDeleteObject = GridDataSource_DeleteObject"></csla:CslaDataSource>
//====Projlist.cs file====
public class ProjList : Csla.ReadOnlyListBase<ProjList, ProjLib.ProjInfo>
//In ProjList in the below method I'm calling the ProjInfo constructor:
private void ExecuteFetch(SqlConnection cn, FilterCriteria criteria)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "sp_GetprojList";
cm.Parameters.AddWithValue("@Id", criteria.ProjId);
//And add other remaining parameters
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while(dr.read())
//pass on the column data to projinfo constructor
ProjLib.ProjInfo info = new ProjLib.ProjInfo(dr.GetInt32("Id"),field2,field3 etc)
}
}
}
//====Projinfo.cs file==== in this file simply initialise the members
//In projinfo constructor I initialise the private members with the values passed.
Now where to set the order explicitly ?? If you mean the order in which am passing the fields in ProjInfo constructor then the columns don't appear in this order.
Can you please shed some light.
Thanks in advance.
--mcdev
Copyright (c) Marimer LLC