Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2006, 11:33 AM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with DataReader/Dataview?

I'm having trouble with something that should be simple...

I have a textbox that contains a value from a database table -categoryname. I want to use that value to search the table when the page loads and return the associated categoryId value to a hidden textbox on the same page.

I know its easy, just can't seem to get the code just right

As always, I appreciate your help....





 
Old December 14th, 2006, 11:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..
do you have already some code??

HTH

Gonzalo
 
Old December 14th, 2006, 11:52 AM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That was fast - I actually just got it to work and was coming back to pull my question - Here is what I did so others can benefit. Thanks anyway for your quick response
<asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ ConnectionStrings:OrderConnectionString %>"
          SelectCommand="SELECT [CategoryId] FROM [Categories] WHERE ([CategoryName] = @CategoryName)">
         <SelectParameters>
             <asp:ControlParameter ControlID="category" Name="CateogoryName" PropertyName="Text" Type="String" />
         </SelectParameters>
      </asp:SqlDataSource>

      <asp:TextBox
          id="CateoryIdTextBox"
          runat="server"
          DataTextField="CateogoryId"
          DataSourceID="SqlDataSource1">
      </asp:TextBox>

 
Old December 14th, 2006, 12:13 PM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I spoke too soon. Above code does not work with TextBox only with ListBox. I guess the DataReader is returning a list of values even though only one row in the table meets the criteria. Can you help me out with the code to display the selected row in a TextBox?

Thanks!

 
Old December 14th, 2006, 01:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I only know how to do it in code... sorry... as far as I know you can't bound a text box to a datasource..

HTH

Gonzalo





Similar Threads
Thread Thread Starter Forum Replies Last Post
dataview Yasho VB.NET 2002/2003 Basics 1 May 28th, 2007 03:40 AM
DataView Not Sorting pbyrum C# 3 December 27th, 2004 06:30 PM
Ordering a dataview Louisa VB.NET 2002/2003 Basics 1 November 11th, 2004 10:04 AM
making changes to dataview bluelaser VS.NET 2002/2003 0 September 20th, 2004 10:15 PM
DataView vivi C# 4 November 10th, 2003 01:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.