How to set value of a SqlDataSource parameter in HTML code?

K

K B

Hi,

I have a gridview with a SqlDataSource. One of the parameters I need to
use in the update is the logged on person. The parameter was created
automatically, but I need to override the value with the "new" person
doing the update (e.g., sUser).

How can I do this please?

<asp:parameter Name="LastUpdatedBy" Type="String" />

Thanks!
Kit
 
G

Guest

How about:
protected void Page_Load(object sender, EventArgs e)
{
SetQueryParamter();
}
private void SetQueryParameter()
{
MySqlDataSource.SelectParameters["LastUpdatedBy"].DefaultValue = sUser;
}
 
K

Kees de Winter

That should work. An alternative would be to put the following in the
Page_Load:

SQLDataSource.UpdateParameters.Add(ParameterNameWithoutTheAtSymbol, Value)
Where you need to make sure that the parameter is not yet created.
(thanks to 'clickon' who answered the same kind of question to me
yesterday).

--
Kees de Winter


Dabbler said:
How about:
protected void Page_Load(object sender, EventArgs e)
{
SetQueryParamter();
}
private void SetQueryParameter()
{
MySqlDataSource.SelectParameters["LastUpdatedBy"].DefaultValue = sUser;
}


K B said:
Hi,

I have a gridview with a SqlDataSource. One of the parameters I need to
use in the update is the logged on person. The parameter was created
automatically, but I need to override the value with the "new" person
doing the update (e.g., sUser).

How can I do this please?

<asp:parameter Name="LastUpdatedBy" Type="String" />

Thanks!
Kit
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top