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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:56:26+00:00 2026-05-16T18:56:26+00:00

Tell me if this is even possible: I have a gridview bound to an

  • 0

Tell me if this is even possible:

I have a gridview bound to an ObjectDataSource providing me with data from a database. I’m filling the Objectdatasource using Linq-to-entities. Typical setup where I’m supplying the columns and rows.

Below I have a horrible graphical representation.


       x_col    x_col   x_col   
x_row| x_data   x_data  x_data    
x_row| x_data   x_data  x_data  
x_row| x_data   x_data  x_data  
x_row| x_data   x_data  x_data    
x_row| x_data   x_data  x_data   

What I would like to do is add columns to this gridview from another table in the database: orginal data being x; different data being y.


       x_col    x_col   x_col   y_col   y_col   y_col 
x_row| x_data   x_data  x_data  y_data  y_data  y_data
x_row| x_data   x_data  x_data  y_data  y_data  y_data
x_row| x_data   x_data  x_data  y_data  y_data  y_data
x_row| x_data   x_data  x_data  y_data  y_data  y_data  
x_row| x_data   x_data  x_data  y_data  y_data  y_data 

I don’t know any of the y info until runtime, so that is added dynamically. I don’t need to update x back to the database, but I do need to update y.

It looks like the datasource can only have once select method, so I don’t know how I can do this.

I hope I’m not being too abstract here.

  • 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-16T18:56:27+00:00Added an answer on May 16, 2026 at 6:56 pm

    The short answer is yes, you can dynamically change/regenerate the columns of a GridView. The easiest way to do so is to programatically define the DataSource before DataBinding. The DataSource can be an IEnumerable of practically any object, allowing you to create a custom GridRow object that holds the data in the form you wish to view it.

    Here’s what I would do, at a high level:

    • Remove the static column definitions from your GridView in the markup, and set the property AutoGenerateColumns to true on the GridView itself. This will cause the GridView to create columns on DataBinding based on the object used as the DataSource.

    • Create a simple, POCO class to represent each set of data you want to show. If the number of different column arrangements is going to be large, or cannot be known at compile-time, it may be worth the overhead to pull or push the data into a DataTable.

    • When preparing your results, transfer the data into a list of the applicable POCO class, or into the DataTable. Set this List or DataTable as the DataSource, and call DataBind()

    • Custom labels can be specified programmatically; the system will default to the ToString() representation of the field, property or column name of its DataSource object. You can override this behavior by attaching a handler to the OnDataBinding event of the GridView, or simply changing column names after calling DataBind().

    Alternately, you can choose to not create columns automatically, but still do so dynamically on page load or PreRender. This will allow you to control all the specifics yourself, without relying on defaults. You can use this to create various dynamic grids that will all map to fields of the same data object, reducing your class count somewhat.

    Dynamic grid creation is useful for things like search pages, where you may want to look for one type of record out of many, but don’t want to have a pre-defined GridView for everything you’re able to search for, nor have to normalize the search results so they all fit in a similar grid.

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

Sidebar

Related Questions

I don't know if this is even possible but we'll see... I have a
Can anyone please tell why this error? I have included everything ( all header,
Could someone tell me if this: $.ajax({ url: 'test.html', success: function(data) { alert(Data Loaded:
I'm trying to figure out if this is even possible. When someone clicks (or
I don't know if this is even possible with PHP, but I figured if
How can i tell this java applet to take the .jar file from the
I have to transfer ~100MB of data over ServerSocket using NIO, but I can't
Possible Duplicate: PHP Curl script to pull data from remote server every 10 minutes
This is kinda annoying, but even though I have worked with html/css and tiny
I can't tell if this is a bug or what. The following code works

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.