Perhaps I have not phrased my questions properly.
I might use datasets rather than the SQLDataSource (at this point I don't
know).
Regardless of what I use, my main question is:
How do I get the field data (be it from a SQL statement, or a stored
procedure, etc) into a TextBox? For the sake of learning I can hard-code
parameters in the query, or even have only one record in the table. Every
example I have seen is related to databound controls like Listboxes,
datagrids, etc.
TextBox1.Text = (what does it equal?) (how to I put the data here?)
TextBox1.Text = DataSet.fieldname?
TextBox1.Text = DataSet.Row.Fieldname?
TextBox1.Text = Some other type of syntax?
And are there examples anywhere? I have seen many examples using TextBoxes
to enter data that will be updated to a table, but I have not seen any
examples where the TextBox is used to display data.
I am not trying to display multiple records, so I am not interested in
datagrids.
Eventually (BUT NOT NOW) I plan to have multiple TextBoxes and multiple
DropDowns on a webform (probably 30 to 50 total) from which the user will
read, and edit data. Right now all I need to figure out is how to put data
in a single query (or table) field into a TextBox. I can write the VB code
if I can figure out how to display the data in the TextBox.
Thanks again.
[quoted text, click to view] > Basically, there is no "easy" way to populate the text boxes from any
> in-memory representation of database data without writing the logic to
> select a given field, convert that field to a String (if necessary), then
> assign the string to the text property of a textbox.
>
> I'm not at all sure you've simplified your problem by using the
> SqlDataSource class:
[quoted text, click to view] "kvr901" <kvr901@discussions.microsoft.com> wrote in message
news:7CCF575F-F50D-42C2-8865-A90241A39C26@microsoft.com...
> Please disregard my previous reply. I accidently posted it before
> finishing
> it, and I can't find a way to edit it.
>
>
>
> Thank you for your reply, but I am so lost at this point that I need some
> help with basics. For now, I have given up on datasets, etc., and am
> trying
> to use one "in-line" SQL statement to populate 3 textboxes.
>
> I created a simple table named "TestTable1" with 3 fields.
> Column Name Type
> fldPersonID int
> fldFirstName nvarchar(50)
> fldLastName nvarchar(50)
>
> There are 3 records:
> 1 George Bush
> 2 Bill Clinton
> 3 Ronald Reagan
>
>
>
>
> At this point in time I don't care about parameters. I don't care which
> record
> is displayed in the textboxes. I just want to see how to get the data
> into
> a textbox.
>
> I have searched the net for days, but all I find is how to populate
> datagrids,
> dataviews, datareaders, etc. I want my data in textboxes.
>
> My connection string works fine, and I can query the data fine using
> datagrids.
>
>
> Any help would be appreciated.
>
>
>
> What I have so far:
>
> Dim testDataSource As New SqlDataSource()
> testDataSource.ConnectionString =
> ConfigurationManager.ConnectionStrings("TestDataConnectionString1").ToString()
>
>
> testDataSource.SelectCommandType = SqlDataSourceCommandType.Text
> testDataSource.SelectCommand = "SELECT fldPersonID, fldFirstName,
> fldLastName FROM TestTable1"
>
>
> Me.txtboxPersonID.Text =
> Me.txtboxFirstName.Text =
> Me.txtboxLastNameName.Text =
>
>
OK, and which of the three rows returned will be used to populate your text
boxes?
I'm hoping somebody else will jump into this thread, as all I have found is
bad news for you.
Basically, there is no "easy" way to populate the text boxes from any
in-memory representation of database data without writing the logic to
select a given field, convert that field to a String (if necessary), then
assign the string to the text property of a textbox.
I'm not at all sure you've simplified your problem by using the
SqlDataSource class:
Please read here:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource(VS.80,d=ide).aspx
http://msdn2.microsoft.com/en-us/library/703tk8bc(d=ide).aspx
the SqlDataSource class is designed to fill complex controls with data, with
little or no coding. At a minimum, populating text boxes will require that
you either parameterize your SELECT query to limit rows returned to one,
then select columns for display in text boxes, or that you write the logic
to select the row in question from those in the returned dataset.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource(d=ide).aspx
You should also read this article explaining the DataSourceMode property:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.datasourcemode(d=ide).aspx