how do i display column name and rows in datalist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My datareader looks like this where dtrItemList is the datareader and
chklExceptionList is my checkboxlist. the rows come in just fine, but I need
help also including the name of the columns for my rows. I need them listed
only one time on top. Any idea? Thanks in advance.

while (dtrItemList.Read())
{
chklExceptionList.Items.Add(dtrItemList["item_id"].ToString() + " " +
dtrItemList "item_name"].ToString());

}
 
You can get to the column name through the DataReader's GetName method.

string columnName = dtrItemList.GetName( dtrItemList.GetOrdinal(
"item_id" ) );

This will return the name of the column. (which in this case will be
"item_id")

bill
 
Back
Top