DataSets - Class Model - How to get Bool Value from a DataSet
<p>I am new to C# and ASP.net.  I am a ColdFusion Programmer but I am catching on to ASP.net.</p>

<p>I will give details then ask my question....</p>

<p>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.</p>

<p>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.</p>

<p><a href="http://stackoverflow.com/questions/1729062/c-assigning-a-value-to-datarowhaswhatnots-haswhatnots-is-awful-slow">http://stackoverflow.com/questions/1729062/c-assigning-a-value-to-datarowhaswhatnots-haswhatnots-is-awful-slow</a></p>

<p>I see a mention that they should... </p>

<p>Alternatively - use a class model instead of a DataTable that sounds great if it is what I think it is.</p>

<p>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?</p>

<p>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...</p>

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

<p>Thanks for any help,
Nathan</p>

<p>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. </p>

<pre><code>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 &lt; 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
}
}
}
</code></pre>
