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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:59:03+00:00 2026-06-12T14:59:03+00:00

I’m trying to read items from a DataTable into a webpage, but getting 2

  • 0

I’m trying to read items from a DataTable into a webpage, but getting 2 errors in the C# code: p1.InnerHTML = dt.rows(0).Item(0);

Errors:

p1 does not exist in the current content.
System.Data.Datatable does not contain a definition for ‘rows’ and no extension method ‘rows’ accepting a first argument ..

C#

protected void Page_Load(object sender, EventArgs e)
{
    DataTable dt = new DataTable();
    string strConnection = ConfigurationManager.ConnectionStrings["ChinatowndbConnString"].ConnectionString;
    SqlConnection conn = new SqlConnection(strConnection);
    string sql = "SELECT pagetext FROM Content where pagetag = 1";
    SqlCommand cmd = new SqlCommand(sql);
    cmd.CommandType = CommandType.Text;
    cmd.Connection = conn;
    SqlDataAdapter sd = new SqlDataAdapter(cmd);
    sd.Fill(dt);

    p1.InnerHTML = dt.rows(0).Item(0);
    p2.InnerHTML = dt.rows(1).Item(0);
    p3.InnerHTML = dt.rows(2).Item(0);
}

HTML:

<p id="p1" class="none"></p>
<p id="p2" class="none"></p>
<p id="p3" class="none"></p>

Any ideas how to get my code working,

Thanks
Tea

  • 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-12T14:59:04+00:00Added an answer on June 12, 2026 at 2:59 pm
    1. p is a html element, you must add runat=server if you want to access it on serverside
    2. C# is case-sensitive and the property is called Rows instead of rows

      <p id="p1" runat="server" class="none"></p>
      <p id="p2" runat="server" class="none"></p>
      <p id="p3" runat="server" class="none"></p>
      

    Furthermore, in C# an arry indexer is accessed via square brackets instead of parentheses. But i would suggest to use the DataRow.Field extension method instead:

    p1.InnerHtml = dt.Rows[0].Field<String>(0); // first field of first row, assuming that it's a string
    

    Final note: you have also mispelled InnerHtml. Visual Studio can correct it automatically for you if the cursor is somewhere in InnerHTML and you press Ctrl+Space.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
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
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.