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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:20:28+00:00 2026-05-11T05:20:28+00:00

I have a DataGrid that looks like this (slightly simplified here): <asp:DataGrid ID=grdQuotas runat=server

  • 0

I have a DataGrid that looks like this (slightly simplified here):

<asp:DataGrid ID='grdQuotas' runat='server' AutoGenerateColumns='False'>     <HeaderStyle CssClass='quotas-header' />     <Columns>         <asp:TemplateColumn>             <HeaderTemplate>                 Max order level</HeaderTemplate>             <ItemTemplate>                 <asp:DropDownList ID='ddlMaxOrderLevel' runat='server' DataSourceID='xdsOrderLevel'                     DataTextField='Text' DataValueField='Value' SelectedValue='<%# Bind('MaxOrderLevel') %>'>                 </asp:DropDownList>             </ItemTemplate>         </asp:TemplateColumn>     </Columns> </asp:DataGrid>  <asp:XmlDataSource ID='xdsOrderLevel' runat='server' DataFile='~/App_Data/OrderLevels.xml'> </asp:XmlDataSource> 

In my Page_Load event handler I am creating a DataTable containing default values and DataBinding it to the DataGrid.

The problem is that this is taking place before the DropDownList ddlMaxOrderLevel has been bound to its DataSource, so I get a runtime error telling me that the SelectedValue cannot be set.

If ddlMaxOrderLevel was not in a DataGrid I could just call DataBind() on it. However I cannot do that in this scenario – since it is in an ItemTemplate.

Can anyone suggest a workaround or alternate approach?

  • 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. 2026-05-11T05:20:28+00:00Added an answer on May 11, 2026 at 5:20 am

    Create another DataSource and bind it to the DataGrid. Where the SelectMethod would return the default values in a simple object.

    Then all the binding should happily work together.

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

Sidebar

Related Questions

I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I have a datagrid column that I am using an itemRenderer. Something like this
I have an object that looks like this: [Bindable] public class MyRecord implements ValueObject
Lets say I have a custom data type that looks something like this: public
I would like to have a datagrid that is transposed in flex. I believe
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public
Hello I'm having a problem here. The code looks like this. private void Form3_Load(object
I have a DataGrid that represents layers - each row is an image on
I have a datagrid that is filled with a dataset from an SQL query.
I have a datagrid that I want to add a button/s to at runtime.

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.