I am new to .net and I am using Visual Web Developer 2005 Express with SQL Server 2005 Express. What I would like to do is connect to my SQL database (which resides in the app_data folder) and open a table and pull out a field and place it in either a textbox or label on the page. No editing or deleting. Just simple one field binding. By the way, I can do this with all the cool built-in tools of VWD, but I want to know how to do it all by hand. I would really appreciate it if someone could help me out.
nate200@.hotmail.com:
I am new to .net and I am using Visual Web Developer 2005 Express with SQL Server 2005 Express. What I would like to do is connect to my SQL database (which resides in the app_data folder) and open a table and pull out a field and place it in either a textbox or label on the page. No editing or deleting. Just simple one field binding. By the way, I can do this with all the cool built-in tools of VWD, but I want to know how to do it all by hand. I would really appreciate it if someone could help me out.
This should give you an idea, it's a very manual example, no flashy tools:
http://aspnet.4guysfromrolla.com/articles/110905-1.aspx
Roger|||
Hey thanks that helped a lot! I got the code in place but when I view the page I don't get anything in my label. Here's my code.
<
formid="form1"runat="server"><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PollConn %>"SelectCommand="SELECT TOP 1 MemberNum FROM Members"></asp:SqlDataSource><asp:LabelID="Label1"runat="server"Text='<%# Bind("MemberNum") %>'></asp:Label></form>
What am I missing??
|||nate200@.hotmail.com:
Hey thanks that helped a lot! I got the code in place but when I view the page I don't get anything in my label. Here's my code.
<formid="form1"runat="server">
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PollConn %>"
SelectCommand="SELECT TOP 1 MemberNum FROM Members"></asp:SqlDataSource>
<asp:LabelID="Label1"runat="server"Text='<%# Bind("MemberNum") %>'></asp:Label>
</form>
What am I missing??
When using a data source you need to wrap a formview tag around the label, and bind the formview to the datasource.
Here's some samples of the formview tag:
http://www.asp.net/QuickStart/aspnet/doc/ctrlref/data/formview.aspx
Roger
No comments:
Post a Comment