Help with Databinding

Reply

Join Date: Dec 2004
Posts: 2
Reputation: Horizon is an unknown quantity at this point 
Solved Threads: 0
Horizon Horizon is offline Offline
Newbie Poster

Help with Databinding

 
0
  #1
Dec 22nd, 2004
I am trying to databind one entry retrieved from a SQL statement.

All I want to do is databind in the code behind page.

For some reason I have lost my brain and cannot figure out how to do it....
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Help with Databinding

 
0
  #2
Dec 22nd, 2004
Databind WHAT to WHAT? You have your data in SQL, you get it out and it's now inside, what? A DataReader? DataTable?

You want to bind this data to which ASP.NET Server control?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2
Reputation: Horizon is an unknown quantity at this point 
Solved Threads: 0
Horizon Horizon is offline Offline
Newbie Poster

Re: Help with Databinding

 
0
  #3
Dec 22nd, 2004
Sorry I should have made myself clearer.

I was trying to databind to a label, and just found an easier way. Through the use of the Command Object.

I was losing my train of thought and went on to post the question but didnt realize I left out the main reason.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Help with Databinding

 
0
  #4
Dec 22nd, 2004
Which Command object? For SQL Commands?
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Help with Databinding

 
0
  #5
Dec 22nd, 2004
Yes, sorry to say but you are not being very clear in what you are wanting to do.

Have you successfully connected to the SQL Server DB?

You can use a Container to the specific Value you want to associate with the LABEL Object.

Below is a sample to this code:
<asp:Label id="label1" runat="server"
  Text='<%# Container.DataItem("CustomerName") %>




Hope this helps!

Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: jturlington is an unknown quantity at this point 
Solved Threads: 0
jturlington jturlington is offline Offline
Newbie Poster

Re: Help with Databinding

 
0
  #6
Jun 27th, 2005
So, would you use it like this:

  1. <tr><td colspan="2"><hr color="#F53167" width="100%" size="3"></td></tr>
  2. <tr><td colspan="2">
  3. <form id="form1" runat="server">
  4. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tcmConnectionString1 %>" SelectCommand="SELECT * FROM [prod]">
  5. </asp:SqlDataSource>
  6. <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:tcmConnectionString1 %>" SelectCommand="SELECT [prod_description] FROM [prod] WHERE ([ID] = @ID)">
  7. <SelectParameters>
  8. <asp:ControlParameter ControlID="DropDownList1" Name="ID" PropertyName="SelectedValue"
  9. Type="Int64" />
  10. </SelectParameters>
  11. </asp:SqlDataSource>
  12. <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
  13. DataTextField="prod_name" DataValueField="ID">
  14. </asp:DropDownList><br />
  15. &nbsp;<asp:Label ID="Label1" runat="server" Text='<%# SQLDataSource2.DataItem("prod_description") %>'></asp:Label>
  16. </form></td></tr>
  17. </table>

I am pretty sure I am way off.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Help with Databinding

 
0
  #7
Jun 27th, 2005
Please wrap your code in code tags. Please start a new thread, rather than posting your question as a reply to a resolved thread.

With ASP.NET, it's best practice to separate your pages into an "HTML" template, and a code-behind file.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: jturlington is an unknown quantity at this point 
Solved Threads: 0
jturlington jturlington is offline Offline
Newbie Poster

Re: Help with Databinding

 
0
  #8
Jun 27th, 2005
editted post
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Help with Databinding

 
0
  #9
Jun 27th, 2005
Edited...ok. But what are you asking still?

Originally Posted by jturlington
editted post
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: jturlington is an unknown quantity at this point 
Solved Threads: 0
jturlington jturlington is offline Offline
Newbie Poster

Re: Help with Databinding

 
0
  #10
Jun 27th, 2005
to have the dropdownlist change what the text of the label is.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 11933 | Replies: 11
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC