B
Bob
Hi,
I want to get the picture into the imagebutton, but from code-behind.
I did this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Using mConnection As New SqlConnection(param.ConnectionString)
sql = "select pict from artikels where hfd='n1'"
comd = New SqlCommand(sql, mConnection)
mConnection.Open()
dtreader = comd.ExecuteReader
dtreader.Read()
'imagebutton1 does exist in aspx file
img1 = FindControl("imagebutton1")
img1.ImageUrl = dtreader.GetString(0)
But this gives only a red cross as image because the directory of the
pictures is not specified.
What i try to do is the equivalent as the Eval function like this:
<asp:ImageButton runat="server" ImageUrl='<%# Eval("pict","mypict\{0}") %>'
/>
How can i do that in code-behind?
Thanks
Bob
I want to get the picture into the imagebutton, but from code-behind.
I did this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Using mConnection As New SqlConnection(param.ConnectionString)
sql = "select pict from artikels where hfd='n1'"
comd = New SqlCommand(sql, mConnection)
mConnection.Open()
dtreader = comd.ExecuteReader
dtreader.Read()
'imagebutton1 does exist in aspx file
img1 = FindControl("imagebutton1")
img1.ImageUrl = dtreader.GetString(0)
But this gives only a red cross as image because the directory of the
pictures is not specified.
What i try to do is the equivalent as the Eval function like this:
<asp:ImageButton runat="server" ImageUrl='<%# Eval("pict","mypict\{0}") %>'
/>
How can i do that in code-behind?
Thanks
Bob