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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:34:14+00:00 2026-06-07T06:34:14+00:00

I have DataTable in my application. It holds DataColumns and Rows. I just want

  • 0

I have DataTable in my application. It holds DataColumns and Rows. I just want to call it recursively and input to InnerXml query. here Field names should be DataColumns values and Value should be Row value of DataTable. Bellow is my tried code. But I don’t have idea to iterate DataTable and fill InnerXml.

    DataTable DT = new DataTable();

    for(int i=0 ; i<DT.Length ;i++){
               batchElement.InnerXml =
               "<Method ID='4' Cmd='New'>" + "<Field Name='" + DT.DataColumn[] + "'>" + DT.row + "</Field></Method>";

    }

Please help me.

  • 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-07T06:34:15+00:00Added an answer on June 7, 2026 at 6:34 am

    Do you want to simply enumerate a DataTable or do you actually want to recursively iterate it? I only ask because you example code does not show recursion, it shows enumeration with a couple parts that won’t compile.

    I’m guessing that you are attempting to serialise the datatable, in which case the following example would probably work:

    StringBuilder innerXml = new StringBuilder();
    int methodId = 0;
    foreach(DataRow row in DT.Rows)
    {
        innerXml.AppendFormat("<Method ID='{0}' Cmd='New'>", methodId.ToString());
        methodId += 1;
    
        foreach(DataColumn column in DT.Columns)
        {
            innerXml.AppendFormat("<Field Name='{0}'>{1}</Field>", column.ColumnName, row[column.ColumnName]);
        }
    
        innerXml.AppendLine("</Method>");
    }
    batchElement.InnerXml = innerXml.ToString();
    

    Apologies if the above does not compile – handtyped – should hopefully put you on the right track though.

    NB: I’m not really sure, based on your example, how you intend to split the row and cell elements in Xml. I’ve made some assumptions on the Xml structure but hopefully it’s enough for you to work from

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

Sidebar

Related Questions

I want to bind datagridview in windows application with dynamically changed datatable. I have
I use yui datatable in my asp.net application... I have a link button in
I have datatable with column name tag and 100 rows of data.I need to
I have a datatable where I want to change the color of a cell
I have a datatable and want it to export it to excel file, it
I am populating one DataGridView in C# windows application. I have one DataTable in
I have this datatable with dynamic columns in my application. I'm trying to figure
I have already developed an application which returns DataTable everywhere. Now my client wants
I have an application that stores users in a database. I want that administrators
I am currently developing a desktop application. I have a DataTable filled up. How

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.