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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:44:28+00:00 2026-05-16T14:44:28+00:00

I have table in my database names User with fields: Id FirstName LastName LoginName

  • 0

I have table in my database names User with fields:

Id
FirstName
LastName
LoginName

Now I would like to present this table in ASPxGridView using LinqServerModeDataSource.

What I did is :

<dxdtlnq:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server"          OnSelecting="LinqServerModeDataSource1_OnSelecting"
  ContextTypeName="MyContext" EnableDelete="True" 
  EnableInsert="True" EnableUpdate="True" TableName="Users" >
</dxdtlnq:LinqServerModeDataSource>

protected void LinqServerModeDataSource1_OnSelecting(object sender, LinqServerModeDataSourceSelectEventArgs e) 
{           
   MyContext context = new MyContext();

   var qry = from s in context.Users select s;
   e.QueryableSource = qry;
}

That works great with my ASPxGridView. I can display data, insert and delete but now I would like to have additional column UserName which is FirstName + LastName.

So I did something like that:

Added appropriate column to my ASPxGridView (FieldName = “UserName”)
and modified OnSelecting handler:

protected void LinqServerModeDataSource1_OnSelecting(object sender, LinqServerModeDataSourceSelectEventArgs e) {
            KozuModelDataContext context = new MyContext();

        var qry = (from s in context.Substitutions
                   select new
                              {
                                  Id = s.Id,
                                  FirstName = s.FirstName,
                                  LastName = s.LastName,
                                  LoginName = s.LoginName,
                                  UserName = s.FirstName + " " + s.LastName,
                              }).AsQueryable();

        e.KeyExpression = "Id";
        e.QueryableSource = qry;
    }

Now data in the grid is displayed buyt when I want to insert or edit data fields cannot be filled, textboxes doesnt respond in inserting form I cant type in any text.

Is there any solution for inserting and editing data in this manner ?

Thanks for help

  • 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-16T14:44:28+00:00Added an answer on May 16, 2026 at 2:44 pm

    I have tried to reproduce this issue and see this behavior. To be able to edit data using this approach, I suggest that you do the following:

    1) Handle the ASPxGridView.CellEditorIntitialize event and set the e.Editor.ReadOnly property to false. This will allow the end-user to modify data in the EditForm editors;

    2) Handle the ASPxGridView.RowUpdating (RowInserting) event and update data manually. Also, you should set the e.Cancel parameter to true (to prevent the grid from updating data itself) and also call the GridView’s CancelEdit method to close the EditForm.

    I should also mention that there is no need to fetch data for the UserName from the DB. This can be done using the ASPxGridView’s CustomColumnDisplayText event handler:

    protected void ASPxGridView1_CustomColumnDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDisplayTextEventArgs e) {
        if(e.Column.FieldName == "") {
            object[] values = ASPxGridView1.GetRowValues(e.VisibleRowIndex, new string[] { "FirstName", "LastName" }) as object[];
            e.DisplayText = values[0].ToString() + " " + values[1].ToString();
        }
    }
    

    If this approach works for you, you can avoid using the Selecting event and thus set the LinqServerModeDataSource’s TableName. This will allow you to provide the data editing feature not using the approach I explained above.

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

Sidebar

Related Questions

No related questions found

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.