Problem with code behind

  • Thread starter Wernfried Schwenkner
  • Start date
W

Wernfried Schwenkner

In a page I have a button. On the code behind in the click event I wan't
to fill a data table of the sql server.

Therefor I have place a SqlDataSource on the page in the designer,
configured all the connections and got the <asp:SqlDataSource>, it's
commands and the <UpdateParameter> for the update command generated.
I wan't to use the update to initialize some fields in my table.

Now I don't know, how to put the data into the update command.

SqlDataSource1.UpdateParameters["Image"] = byteContentOfImage;
SqlDataSource1.Update();

doesn't work, the compiler says
Cannot implicitly convert type 'byte[]' to
'System.Web.UI.WebControls.Parameter'

and a typecast also doesn't work.

How can I fill some data into the parameter?
 
W

Wernfried Schwenkner

I found a way, but I'm not very satisfied.

Instead of using
<asp:parameter Name="Image"/>

I took
<asp:SessionParameter Name="Image" Type="Object" SessionField="Image" />

Then I'm able to assign the byteContent to a Session variable
Session["Image"] = byteContent;

Can this be done not using the session state?
 

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,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top