how do i display column name and rows in datalist

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());

}
 
W

William F. Robertson, Jr.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top