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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:39+00:00 2026-06-13T07:14:39+00:00

Hey guys I’ve just started programming and I’m running into a problem. The new

  • 0

Hey guys I’ve just started programming and I’m running into a problem. The new Datatable i created doesnt show in GridView2 when button1 is clicked. Although it is filled with data from the “planning” table(checked that dtPlanning is filled with the TextBoxes in comment).

So in short: I want to get DataTable planning into the new DataTable dtPlanning and display it in a gridview.

Code Behind:

protected void Button1_Click(object sender, EventArgs e)
{
    DataTable dtPlanning = new DataTable();
    dtPlanning.Columns.Add("Courseday", typeof(int));
    dtPlanning.Columns.Add("Part", typeof(string));
    dtPlanning.Columns.Add("Design", typeof(string));
    dtPlanning.Columns.Add("Lesson", typeof(string));

    //DataRow dr = planning.Rows[1];  
    //TextBox2.Text = (dr["Daynumber"]).ToString();
    //TextBox3.Text = (dr["Part"]).ToString();
    //TextBox4.Text = (dr["Design"]).ToString();
    //TextBox5.Text = (dr["Lesson"]).ToString();

    for (int i = 0; i < dtPlanning.Rows.Count; i++)
    {
        DataRow dr = dtPlanning.NewRow();
        foreach (DataRow datarow in planning.Rows)
        {
            dtPlanning.Rows.Add(datarow);
        }
    }
    GridView2.DataSource = dtPlanning;
    GridView2.DataBind();
}

Source code:

<asp:GridView ID="GridView2" runat="server">

Thank you for your 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-06-13T07:14:40+00:00Added an answer on June 13, 2026 at 7:14 am

    Logically, dtPlanning.Rows.Count = 0 because this table is just initialized!
    Secondly, you cannot Add a row from one table to another, user Import

    for (int i = 0; i < planning.Rows.Count; i++)
    {
        dtPlanning.ImportRow(planning.Rows[i]);
    }
    

    I wonder why don’t you just use the table planning?

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

Sidebar

Related Questions

Hey guys thanks for answering I'm really new to Android programming(I started today) and
Hey guys, sorry I'm kind of new to programming, but I had a small
hey guys having this really simple problem but cant seem to figure out have
Hey guys (and gals) I'm having a problem using Assembly GetExportedTypes() in .NET 4.0.
Hey guys i have been trying to make a NIO server/client program. My problem
Hey guys I just noticed that my join statement here SELECT * FROM reports
Hey guys I can't seem to get the syntax here right, I'm just trying
Hey guys I am new to android development, I am currently making an application.The
Hey guys I'm using python and I was just wondering how we can make
Hey guys I've been programming OOP for a semester now in C++ and I

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.