Sunday, February 19, 2012

How to copy query result to a label?

Hi,

I want to run a select query and copy the result to a label. I created a SqlDataSource1, but I don't know how to go ahead.

I would like to do something like:

string x = SqlDataSource1.SelectCommand

Please, advice!

label takes values of 1D. Your SQL results are 2D. How do you expect to bind them together? You would need a data control such as datagrid/gridview etc.

|||The same way most people would think -- assume your talking about the first row always. Unfortunately ASP.NET is a pain that way -- You have to bind the datasource to a control that understands row traversing first (Even if your query only returns one row, which is stupid), place all your labels within that control, and then you can bind them to a particular column.

No comments:

Post a Comment