473,795 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! C# - SqlDataSource to TextBox (asp.net)

Hi,

I'm new to C# and Visual Studio 2005 and very confused trying to do a
very simple thing (I think).
All I want to do is: when a page loads it runs a query on a table in a
database and displays the fields in various text boxes on the page.
I've added the SqlDataSource to the page ok; added the textbox ok; but
how do I bind the results of the query to the textbox?!?! Should be
so simple but I keep finding VS2003 examples

protected void Page_Load(objec t sender, EventArgs e)
{
SqlDataSource1. SelectCommand = "select name from person where
person_id = 1";
//TextBox1.Text = result of above command!!!!!!

}

I'd be very grateful for any advice/suggestions/dummies guide on how to
do this. While I'm here, can anyone recommend a good c#/asp.net book?

Thank you!!

deegee

Jan 31 '06 #1
1 11799
Hello,

you can find more about DataBase transactions using .net with examples at
http://www.asp.net/QuickStart/howto/...contents.aspx#
--------------------
From: de****@360compu ting.net
Newsgroups: microsoft.publi c.dotnet.genera l
Subject: Help! C# - SqlDataSource to TextBox (asp.net)
Date: 31 Jan 2006 12:24:46 -0800
Organization : http://groups.google.com
Lines: 25
Message-ID: <11************ *********@o13g2 000cwo.googlegr oups.com>
NNTP-Posting-Host: 84.92.58.58
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google. com 1138739091 29385 127.0.0.1 (31 Jan 2006 20:24:51 GMT)X-Complaints-To: gr**********@go ogle.com
NNTP-Posting-Date: Tue, 31 Jan 2006 20:24:51 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5,gzip(gfe),g zip(gfe)Complaints-To: gr**********@go ogle.com
Injection-Info: o13g2000cwo.goo glegroups.com; posting-host=84.92.58.5 8;
posting-account=u77Y9A0 AAACjf8FIddbT6U MJE9WmXe8e
Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onli
ne.de!news.glor b.com!postnews. google.com!o13g 2000cwo.googleg roups.com!not-fo
r-mailXref: TK2MSFTNGXA02.p hx.gbl microsoft.publi c.dotnet.genera l:187669
X-Tomcat-NG: microsoft.publi c.dotnet.genera l

Hi,

I'm new to C# and Visual Studio 2005 and very confused trying to do a
very simple thing (I think).
All I want to do is: when a page loads it runs a query on a table in a
database and displays the fields in various text boxes on the page.
I've added the SqlDataSource to the page ok; added the textbox ok; but
how do I bind the results of the query to the textbox?!?! Should be
so simple but I keep finding VS2003 examples

protected void Page_Load(objec t sender, EventArgs e)
{
SqlDataSource1. SelectCommand = "select name from person where
person_id = 1";
//TextBox1.Text = result of above command!!!!!!

}

I'd be very grateful for any advice/suggestions/dummies guide on how to
do this. While I'm here, can anyone recommend a good c#/asp.net book?

Thank you!!

deegee


--

Thank You,
Nanda Lella,

This Posting is provided "AS IS" with no warranties, and confers no rights.

Feb 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1201
by: HelpNeeded | last post by:
Case #1 I am facing some problem for dipalying Japanese Charectors with ASP.NET. I used "charset=SHIFT-JIS" in the meta tag.(Code is shown below). When i run this code, the Encoding value of browser showing as "Unicode (UTF-8)" only but it should be "Japnese Shift-JIS".
2
1312
by: TJS | last post by:
is there a downloadable chm help file for asp.net ?
1
1683
by: JeffDotNet | last post by:
I have been enjoying the declarative use of the new sqlDataSource in asp2.0. It makes paging and query building extremely quick and simple. However occasionally I expect to get a timeout exception. Without filling the sqlDataSource manually I don’t know how to go about catching an exception. (Most likely but not limited to a timeout exception) I certainly don’t want to leave an unhandled the exception. And I would like to give a...
1
6858
by: ryanb31 | last post by:
When I call databind on my gridview which uses a SqlDataSource as its DataSourceID, after 30 seconds I get the error "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." I have tried the Connect/Connection TimeOut property in my connection string and have used values between 0 and 600 and it has had no affect. I can run the stored procedure through Query Analyzer. It...
1
1633
by: Developer | last post by:
Dear Group Member, I am sorry if I have posted this query in wrong group, but since this is connected with ASPO.NET2.0, thought of posting here. I am doing a very simple program where I am inserting Grid control, SQL datasource control. I am attaching the default Northwind database to this Sql Datasource and binding this to the grid control. When I click test connection on the Sql Datasource, it says conncetion succeded. Now I am...
6
2052
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the data that was retrieved by the query. At times I may want the display control only to render some items in the set of data returned by SqlDataSource. There would be several scenarios: * render the second data item or third item in to the end...
6
2416
by: SenthilVel | last post by:
hi all, i am running a ASP.Net 2.0 application. in one of the pages i have a text box which is set as PASSWORD mode. when the page is submitted or transfered , am not able to get the contents of this textbox which is in Password mode. do we need to any more apart from setting to password mode to get the value present in the text box..? do we need to do anything in specific with the viewstates if there is
2
5513
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
2
2648
by: Kanwal jeet | last post by:
The max length property are not work in the Asp.Net TextBox control. <asp:textbox ID="txComment" MaxLength="20" Width="90%" Columns ="5" Height="100px" TextMode ="MultiLine" runat="server"></asp:textbox>
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.