Hi,
I have asummary table like this
Columns are obviously fixed, but not rows.
I want to show this data using lables and SqlDataReader for report purpose like;
Label1.text=dr("value16").toString()
Label2.text=dr("value28").toString()
Label3.text=dr("value31").toString() etc
Do you have any idea how i can do it or am I approaching it in the wrong way??
Thanks.
Michelle
Hi Michelle,
Are you trying to put the values of the table to a set of Label controls?
If so, you have to use field name as argument, like
Label1.Text = dr("Field1").ToString()
When you need to advance to the next row, you have to call dr.Read(). So the best way is to put this in a loop.
If you want to put the whole table in a gridview, you can use GridView.DataSource = dr directly, and call DataBind(). This will make your GridView bind to the DataReader.
HTH.
No comments:
Post a Comment