TonyReba
asked on
How do I bind to a label from a SqlDataSource
I want to pull the Womens Census Value
protected void Page_Load(object sender, EventArgs e)
{
DataView dvSql = (DataView)SqlDataSource4.S elect(Data SourceSele ctArgument s.Empty);
foreach (DataRowView drvSql in dvSql)
{
lbl_Womens_Census.Text = drvSql["Womens_Census"].To String();
}
protected void Page_Load(object sender, EventArgs e)
{
DataView dvSql = (DataView)SqlDataSource4.S
foreach (DataRowView drvSql in dvSql)
{
lbl_Womens_Census.Text = drvSql["Womens_Census"].To
}
Data Source
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:appdevConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:appdevConnectionString1.ProviderName %>"
SelectCommand="SELECT [ID], [Date], [NT1_Census], [NT1], [NT1_Status], [NT2_Census], [NT2], [NT2_Status], [NT3_Census], [NT3], [NT3_Status], [ICU_Census], [ICU], [ICU_Status], [SDU_Census], [SDU], [SDU_Status], [Tele3rd1_Census], [Tele3rd1], [Tele3rd1_Status], [Tele3rd2_Census], [Tele3rd2], [Tele3rd2_Status], [Tele4th1_Census], [Tele4th1], [Tele4th1_Status], [Tele4th2_Census], [Tele4th2], [Tele4th2_Status], [Pedi3rd_Census], [Pedi3rd], [Pedi3rd_Status], [Pedi4th_Census], [Pedi4th], [Pedi4th_Status], [PICU_SD_Census], [PICU_SD], [PICU_SD_Status], [ER_Census], [ER], [ER_Status], [MICU_Census], [MICU], [MICU_Status], [CPV_Census], [CPV], [CPV_Status], [CVOR_Census], [CVOR], [CVOR_Status], [CLOF_Census], [CLOF], [CLOF_Status], [CVOR_HOLDING_Census], [CVOR_HOLDING], [CVOR_HOLDING_Status], [Behavioral_Census], [Womens_Census], [Rehab_Census] FROM [tb_Bed_Control_Possible]">
</asp:SqlDataSource>
http://www.mikesdotnetting.com/Article/64/Bind-Data-From-a-SqlDataSource-to-a-Label
ASKER
I am trying to do the simplest and best way to set the text to the label, can you tell me how/??
possibly modify my snippet above
possibly modify my snippet above
Check if you are getting data in DataView properly?
If yes, then you should get value in your label.
If yes, then you should get value in your label.
ASKER
I am trying not to use DataView, or Gridview , only the Label control
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is comming across now, thank you