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 7990697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:05:28+00:00 2026-06-04T13:05:28+00:00

I am required to use the DevExpress ASPxGridView. I have a datasource Object which

  • 0

I am required to use the DevExpress ASPxGridView. I have a datasource Object which returns two columns of importance, ObjectType and ObjectID. ObjectType can be Patient or or Physician. ObjectID is a int value giving the ID of the Patient or Physician. Hopefully this makes sense. The ObjectID is selected by either the Patient table or the Physician table, they are indendent tables so I can’t join them in any way.

The table structure looks like this:

Object table: ObjectType varchar (“Physician” or “Patient”), ObjectID int

Dogs Table ID int, Name varchar

Cats table ID int, Name varchar

I have been able to write the appropriate objectType by a combobox, and the ObjectID by using two controls, cbPatient and cbPhysician, which are populated by datasources.

What I can’t figure out is when I edit the ASPxGridView, how can I show in cbPatient or cbPhysician the object value. For example if ObjectType is Cats and ObjectID is 1 then I want to show in cbCats the name that corresponds with ID of 1.

This is how the code looks. Right now, for whatever reason the selected value goes blank at some point, in some event. I’m not sure what event to run this code in.

protected void grid_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
{
    if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.EditForm) return;
    if (grid.IsNewRowEditing || grid.IsEditing)
    {
        int val = (int)grid.GetRowValues(grid.EditingRowVisibleIndex, "ObjectID" );

        ASPxComboBox cbPatient = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(grid.Columns["PatientID"] as GridViewDataComboBoxColumn, "cbPatient"));
        if (val != 0)
        {
            string objectID = grid.GetRowValues(grid.EditingRowVisibleIndex, "ObjectID").ToString();

            if (cbPatient.Items.Count > 0)
            {
                cbPatient.Items[1].Selected = true;
            }
            else
            {
                cbPatient.DataSource = dsPatName;
                cbPatient.DataBindItems();
                if (cbPatient.Items.Count > 0)
                    cbPatient.Items[1].Selected = true;
            }

        }
    }

}

This is the ASPX code.

</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataComboBoxColumn Caption="Patient Name" FieldName="PatientID"  Name="PatName"  Visible="false">
    <PropertiesComboBox TextField="Name" ValueField="ID" ValueType="System.Int32"></PropertiesComboBox>
    <EditItemTemplate>
        <dx:ASPxComboBox ID="cbPatient" runat="server"  TextField="Name" ValueField="ID"
        Value='<%# Bind("PatientID") %>' AutoPostBack="false" ValueType="System.Int32" > </dx:ASPxComboBox>
    </EditItemTemplate>
</dx:GridViewDataComboBoxColumn>
  • 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-06-04T13:05:29+00:00Added an answer on June 4, 2026 at 1:05 pm

    I finally figured out that the combobox fires a DataBound event after databinding, which occurs after the RowEditting event (or whatever it is called). The best solution I found was this code. Maybe there is a more elegant solution but this works. The session variable is there to avoid having the code fire when doing the row update (yeah it fires then too, don’t ask me why).

    protected void cbPatient_DataBound(object sender, EventArgs e)
    {
        object rightsindex = grid.GetRowValues(grid.EditingRowVisibleIndex, "Rights");
        if (rightsindex == null) return;
        int rights = Int32.Parse(grid.GetRowValues(grid.EditingRowVisibleIndex, "Rights").ToString());
        object objectID = grid.GetRowValues(grid.EditingRowVisibleIndex, "ObjectID");
    
        ASPxComboBox cbPatient = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(grid.Columns["PatientID"] as GridViewDataComboBoxColumn, "cbPatient"));
        if (cbPatient != null && cbPatient.Items.Count > 1)
        {
    
            if (rights == 8)
            {
                ListEditItem pt = cbPatient.Items.FindByValue(objectID);
                if (pt != null && Session["PatientID"] == null)
                {
                    cbPatient.Items[pt.Index].Selected = true;
                    Session["PatientID"] = (Int32)pt.Value;
    
                }
            }
                //cbPatient.Items[1].Selected = true;
        }
    }
    

    And in the ASP.NET

    <dx:GridViewDataComboBoxColumn Caption="Patient Name" FieldName="PatientID"  Name="PatName"  Visible="false">
        <PropertiesComboBox DataSourceID="dsPatName" TextField="Name" ValueField="ID" ValueType="System.Int32">
        </PropertiesComboBox>
        <EditItemTemplate>
            <dx:ASPxComboBox ID="cbPatient" runat="server" DataSourceID="dsPatName" TextField="Name" ValueField="ID"
            Value='<%# Bind("PatientID") %>' AutoPostBack="false" ValueType="System.Int32" ondatabound="cbPatient_DataBound" > </dx:ASPxComboBox>
        </EditItemTemplate>
    </dx:GridViewDataComboBoxColumn>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am required to use the DevExpress ASPxGridView. I have a datasource Object which
I am working on a project for which we are required to use transaction
I'm working on a homework assignment in which I'm required to use char arrays
Is if almost always required to have thread syncing (i.e. use of mutex, semaphores,
In Objective-C I use a Notification to do some tasks, which required some time
Could someone tell me which version of MySql is required to use Doctrine2 ?
I have a problem with jQuery Validator. I want to use required property on
I am required to use Joomla for a project which essentially consists of several
i have a client who is required to use specific tracking that is only
Is there any jar required to use WSClient class? If yes, can anyone please

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.