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

  • Home
  • SEARCH
  • 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 1041677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:23:23+00:00 2026-05-16T15:23:23+00:00

Im using LinqDataSource like that: <asp:LinqDataSource ID=LinqDataSource3 runat=server OnSelecting=LinqDataSource3_OnSelecting> </asp:LinqDataSource> And I have ASPxGridView

  • 0

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

  • 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-05-16T15:23:24+00:00Added an answer on May 16, 2026 at 3:23 pm

    Answering your first question, I would like to tell you that the code to create columns is better to move to the Page_Load event.

    As for your second question. I think that it is a good solution to provide a custom IQueriable within the Selecting event of the LinqDataSource object. You may fetch data from several tables there. For an example, please refer to:

    Select from multiple table using LINQ

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

Sidebar

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.