ViewState Value as Parameter for SQLDataSource

D

Dave

Is it possible to use a ViewState Value as a Parameter for a
SQLDataSource? Looking at the options available as a Parameter
Source...it looks like no. But I'm being told that you can.

Comments/instructions?

Thanks
 
Joined
Dec 21, 2009
Messages
2
Reaction score
0
Not directly but you could always do something like :
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
e.Command.Parameters("whatever") = ViewState("whatever")

End Sub

Which is what it does in the background anyways
You just leave it blank in the selection screen
 
G

Guest

Is it possible to use a ViewState Value as a Parameter for a
SQLDataSource?  Looking at the options available as a Parameter
Source...it looks like no.  But I'm being told that you can.

Comments/instructions?

Thanks

Dave, you can do this from the code behind. For example, if you need
on select - use SqlDataSource.Selecting Event

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.selecting.aspx

Example:

protected void SqlDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["@OrderID"].Value = ViewState["OrderID"];
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top