Hi,
Im using LinqDataSource like that:
<asp:LinqDataSource ID="LinqDataSource3" runat="server" OnSelecting="LinqDataSource3_OnSelecting">
</asp:LinqDataSource>
And I have ASPxGridView
<dxwgv:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2Client"
runat="server" AutoGenerateColumns="False"
DataSourceID="LinqDataSource3">
</dxwgv:ASPxGridView>
In this way Im able to add columns dynamically while handling onSelecting event:
protected void LinqDataSource3_OnSelecting(object sender, LinqDataSourceSelectEventArgs e)
{
MyModelDataContext context = new MyModelDataContext();
ASPxGridView grid = ASPxPageControl1.TabPages[3].FindControl("ASPxGridView2") as ASPxGridView;
if(grid.Columns.Count == 0){
GridViewDataTextColumn txtColumn1 = new GridViewDataTextColumn();
GridViewDataTextColumn txtColumn2 = new GridViewDataTextColumn();
txtColumn1.FieldName = "UserId";
txtColumn2.FieldName = "FirstName";
grid.Columns.Add(txtColumn1);
grid.Columns.Add(txtColumn2);
}
e.Result = from u in context.Users select new { UserId = u.UserId, FirstName = u.FirstName };
}
It is all made simply to test cause my idea is to have solution that makes it possible to use linqDataSource as a datasource for de ASPxGridView but join 2 or 3 tables and show results in this grid.
What I want to ask is if its good solution or is there any other better way to present some views made from couple of tables by join?
Second question is that I have Users and Group and I would like to have one table in which I would have two columns Name and Type
For groups type would by group and for users type would be user.
I dont have such a table in my database
Is it possible to create specific class. Create List of objects of that class and fill it using linq query and the use it as linq data source for that grid ?
clas would be:
pseudocode:
Class MyClass {
string Type;
string Name;
}
or is there any other way to create such a table ?
thank You very much for help bye