Solved

How do I bind to a label from a SqlDataSource

Posted on 2011-03-07
7
323 Views
Last Modified: 2012-05-11
I want to pull the Womens Census Value

   protected void Page_Load(object sender, EventArgs e)
    {
        DataView dvSql = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView drvSql in dvSql)
        {
            lbl_Womens_Census.Text = drvSql["Womens_Census"].ToString();
        }
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>

Open in new window

0
Comment
Question by:TonyReba
  • 3
  • 2
  • 2
7 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 35063307
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 35063308
0
 
LVL 9

Author Comment

by:TonyReba
ID: 35063321
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
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 9

Expert Comment

by:gery128
ID: 35065936
Check if you are getting data in DataView properly?
If yes, then you should get value in your label.
0
 
LVL 9

Author Comment

by:TonyReba
ID: 35069548
I am trying not to use DataView, or Gridview , only the Label control
0
 
LVL 9

Accepted Solution

by:
gery128 earned 500 total points
ID: 35070056
TonyReba:

you have used this line in your code:
DataView dvSql = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty);

My question was whether you are getting data in DataView  or not? If you are getting than you should be able to iterate through DataViewRows and get the values. Another way is convert your DataView to table by using dvSql.ToTable(); and than iterate through DataTable.

But by your code, the value should come. please check if DataView is populated with data or not.
0
 
LVL 9

Author Closing Comment

by:TonyReba
ID: 35070242
Is comming across now, thank you
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question