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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:06:43+00:00 2026-05-15T23:06:43+00:00

I am new to C# and ASP.net. I am a ColdFusion Programmer but I

  • 0

I am new to C# and ASP.net. I am a ColdFusion Programmer but I am catching on to ASP.net.

I will give details then ask my question….

I have been able to get it where I call from the Code Behind a Service Layer Class File (or Bussiness Logic Layer) then in that one call a Data Access Layer Class file. I have been sending back a DataSet from the Data Access Layer then in the Code Behind moving the code to a table so I can read it row by row.

I was looking for a way to get the Boolean values when I am on the Edit screen to set the check boxes to checked when I found this post.

C# Assigning a value to DataRow["haswhatnots"] = hasWhatnots is awful slow

I see a mention that they should…

Alternatively – use a class model instead of a DataTable that sounds great if it is what I think it is.

What is the Best way to do a CRUD screens where you use the Class file to pull back the data and what format should the Data be in?

I am used to in ColdFusion data coming back in a QuerySet and then we can loop through it. We can convert he query to Array of Structures or and Array of Obects, XML or JSon but I am still running into issues understanding HOW to get the data out of the DataSet when I get it back. I get String Data fine right now but maybe there is a very simple example with maybe one page…

I want to figure out how to get the Boolean values right now is my current issue.

Thanks for any help,
Nathan

P.S. if there is a better more professional way to do this let me know. I want to keep using a (Presentation/CodeBehind/Service/Data Access) type of layers.

Protected void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{

DataTable dt = new DataTable();
DataRow dr;

PageService myPage = new PageService();
DataSet ds = myPage.getPages();

int rowCount = ds.Tables[0].Rows.Count;
ds.Columns.Add(new DataColumn("PageID", typeof(Int32)));
ds.Columns.Add(new DataColumn("Name", typeof(String)));
ds.Columns.Add(new DataColumn("PageHTMLContent", typeof(String)));
ds.Columns.Add(new DataColumn("NavigationText", typeof(String)));
ds.Columns.Add(new DataColumn("TopMenu", typeof(Boolean)));
ds.Columns.Add(new DataColumn("SubMenu", typeof(Boolean)));
ds.Columns.Add(new DataColumn("DisplayOrder", typeof(Int32)));
ds.Columns.Add(new DataColumn("Active", typeof(Boolean)));

for (int i = 0; i < rowCount; i++)
{
  dr = dt.NewRow();
  dr[0] = i;
  dr[1] = i.ToString;
  dr[2] = i.ToString;
  dr[3] = i.ToString;
  dr[4] = i;            // Not sure what to do here for the Boolean Value
  dr[5] = i;  // Not sure what to do here for the Boolean Value
  dr[6] = i;
  dr[7] = i;  // Not sure what to do here for the Boolean Value
}

ds.Tables.Add(dt);
foreach (DataRow dataRow in ds.Tables[0].Rows)
{
  PageIDHiddenField.Value = dataRow["PageID"];
  NameTextBox.Text = dataRow["Name"].ToString();
  PageHTMLContentTextBox.Text = dataRow["PageHTMLContent"];
  NavigationTextTextBox.Text = dataRow["NavigationText"];
  TopMenuCheckBox.Checked = dataRow["TopMenu"];           // Not sure what to do here for the Boolean Value
  SubMenuCheckBox.Checked = dataRow["SubMenu"];           // Not sure what to do here for the Boolean Value
  DisplayOrder.Text = dataRow["DisplayOrder"].ToString();
  ActiveCheckBox.Checked = dataRow["Active"];             // Not sure what to do here for the Boolean Value
}
}
}
  • 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-15T23:06:43+00:00Added an answer on May 15, 2026 at 11:06 pm

    You need to cast the value to the correct type. Because dataRow‘s indexer property will return objects of type object, you need to cast it to the right type. Therefore, you need to cast it to Boolean like so:

    TopMenuCheckBox.Checked = (bool)dataRow["TopMenu"];
    

    To do one loop to iterate over the rows in the DataSet you’d do something like:

    DataSet ds = myPage.getPages();
    
    foreach (DataRow row in ds.Tables[0].Rows)
    {
        PageIDHiddenField.Value = row["PageID"];
        NameTextBox.Text = (string)row["Name"];
        ...
        TopMenuCheckBox.Checked = (bool)row["TopMenu"];
    }
    

    You can use DataRow‘s indexer property to get the specific column.

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

Sidebar

Related Questions

I am new ASP.NET and I have never used a GridView or DataGrid, but
The short question is: I have a webpage in coldfusion / asp.net with many
I have a new ASP.NET MVC project (my first), and I had been running
I'm new to ASP.NET coming from a PHP and ColdFusion background and I have
My team has a new Asp.net MVC intranet app. I have been doing some
I installed the new ASP .Net MVC4 beta on my machine and have been
I'm new to classic asp, all my experience is in c# .net and ColdFusion
New ASP.NET Web API HttpClient has been giving me some strange results. Here is
I have a new asp.net mvc project and i am trying to figure out
I'm planning a new ASP.NET project that will become a product that is installed

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.