AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Expert: Srini Nagarajan Date: 10/12/2007 Subject: pass output to textbox from SQLDataSource
Question QUESTION: Hi,
I've just started using the Visual Web Developer Express Edition 2005, and think it's real cool. I used the SQLDataSource tool to execute a SQL stored procedure. The procedure has a final select statement which displays a bit and string value. The test query runs fine, but I want the string value to pass to a textbox on the same page.
wrote this much:
If Page.IsPostBack=True then
TextBox1.Text= SQLDataSource1. ---??
End if
what do I have to write for that, or is there some way to tie the textbox to the output of the stored procedure using the tool interface?
Thank you!!
ANSWER: Hi
You could use gridview or detailveiw to do this.
Use Gridview and have only TextBox on it.
If you want to display value to textbox use datareader it will be much simpler
-srini
---------- FOLLOW-UP ----------
QUESTION: Thank you. Not sure how to put the textbox in gridview..
Let me explain a little more...
The SQLDataSource is configured to use a stored procedure (under SelectParameters). The aspx page has two text boxes and a button. I need the data entered in these textboxes to pass to the Stored Procedure when I click the button, and then the resulting string "msg" (i.e output of stored procedure) should display in a third text box...
I tired this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = True Then
TextBox3.text= SQLDataSource1.SelectedParameters["msg"].ToString()
End If
End Sub
But it said cannot convert string and that it needs an identifier before the term "msg"...
the gridview displays the output if I send default values but doesn't let me change the values from the webpage.
I'd really appreciate the help!
Answer Hi,
you can try something like this
Dim dv As System.Data.DataView
dv = CType(SQLDataSource1.Select(New DataSourceSelectArguments), DataView)
If dv.Count = 1 Then
TextBox3.Text = dv(0)("["msg")
Else
TextBox3.Text = ""
End If