Gary,
Make a SqlCommand object for the query that will return only one field, then
call its ExecuteScalar method. This will return the ID value. Once you have
the value, you can convert it to string with the ToString method and assign
to your textbox's Text property.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"G" <(E-Mail Removed)> wrote in message
news:7591CBBE-BEDF-4E53-99AF-(E-Mail Removed)...
> Hello,
>
> Fairly new to .net (using c#).
>
> I am running an SQL query which always returns ONE ROW and no more. I
> would like to have the ID field of the returned row bound to a TextBox
> onSubmit.
>
> AT the moment I have used the following controls:
>
> <asp:SqlDataSource ID="DStypes" runat="server" />
> <asp:GridView ID="GVtypes" runat="server"
> DataSourceID="DStypes">
> </asp:GridView>
>
> This returns the entire row, I was using this to test the data returned
> was correct. I would like to amend this code if possible to no longer
> return the datagrid, but simply the value of the ID field, and stick it
> inside my TextBox.
>
> Should I be using SqlDataSource to achieve this?
>
> Regards,
>
> Gary.