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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:57:20+00:00 2026-05-25T20:57:20+00:00

I’m trying to fill a asp.DataGrid with data from a DB2 database. The problem

  • 0

I’m trying to fill a asp.DataGrid with data from a DB2 database. The problem I’m getting is that the data is coming back null. The weird thing is, the records themselves (seem to) load from the database, as when I step through the code while debugging, the DataGrid.Items.Count = the number of records I have in the database itself.

Additionally, while troubleshooting, I’ve added an asp.Label that’s initially hidden to display the number of records found in the DataGrid itself, and each time it displays the correct number of records.

Here’s my code:

protected void Page_Load(object sender, EventArgs e)
{
    dta_grd = new DataGrid();
    dta_grd = Ex_DLL.GetData("select * from tstint/m02");
    Lbl_Dsply.Visible = true;
    if (Supp_Data.Items.Count == 0)
    {
        Lbl_Dsply.Text = "No Records Found!";
    }
    else
    {
        Lbl_Dsply.Text += dta_grd.Items.Count.ToString();
    }
}

Ex_DLL is simply the name of a library that does all the connections to the Database itself.

The Code for Ex_DLL.GetData():

public static DataGrid GetData(string str_sql)
{
    //EX_Global.DB2_Conn("DEV") is just an internal connection function that houses
    //the connection settings.      
    iDB2Connection db2_conn = EX_Global.DB2_Conn("DEV");
    iDB2Command db2_cmd = null;
    iDB2DataAdapter db2_adpt = null;
    DataSet dta_ds = new DataSet();
    DataGrid ret_val = new DataGrid();
    try
    {
        if (db2_conn.State != System.Data.ConnectionState.Open) { db2_conn.Open(); }
        db2_cmd = new iDB2Command(str_sql, db2_conn);
        db2_adpt = new iDB2DataAdapter(db2_cmd);
        db2_adpt.Fill(dta_ds);
        ret_val.DataSource = dta_ds;
        ret_val.DataBind();
        db2_conn.Close();
    }
    catch (Exception) { }
    return ret_val; 
}

Now, when I read them individually using idb2DataReader, it’s actually reading from the database, but there’s just something lost in translation from reading the database to filling the DataGrid itself.

Any ideas?

  • 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-25T20:57:20+00:00Added an answer on May 25, 2026 at 8:57 pm

    There are two problems (may be more) I can see:

    1. You instantiate the DataGrid control during page execution but forget to add it to page’s Controls collection.
    2. You missed Datasource property and DataBind() method.

    In design environment, add a “PlaceHolder” control on a page (.aspx) (Say PlaceHolder1)

    protected void Page_Load(object sender, EventArgs e)
    {
        dta_grd = new DataGrid();
        dta_grd.DataSource = Ex_DLL.GetData("select * from tstint/m02");
        dta_grd.DataBind(); // this method populates the DataGrid from assigned datasource
        PlaceHolder1.Controls.Add(dta_grd);
    
        Lbl_Dsply.Visible = true;
        if (Supp_Data.Items.Count == 0)
        {
            Lbl_Dsply.Text = "No Records Found!";
        }
        else
        {
            Lbl_Dsply.Text += dta_grd.Items.Count.ToString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.