| |

VerySource

 Forgot password?
 Register
Search
View: 1086|Reply: 7

Picture display link, image type

[Copy link]

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-16 09:30:02
| Show all posts |Read mode
As the title, the database is of the image type, what control will be used in aspx to be displayed in the future, and can also be used for linking?
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-10-16 09:45:02
| Show all posts
ImageButton
Reply

Use magic Report

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-10-16 10:15:01
| Show all posts
But the data type in the database is image, how to display it? Is there any example that I can participate in?
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-10-16 11:30:01
| Show all posts
This depends on what content is stored in your Image. If it is a picture, there are a lot of information to read the picture from the database on the Internet. If it is a sound video, you need to use other methods!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-16 14:00:01
| Show all posts
SqlConnection con = new SqlConnection(constr.getCon());
               con.Open();
                SqlCommand cmd = new SqlCommand("insert into organ.organ values(@name ,@photo)", con);
                cmd.Parameters.AddWithValue("@name", name);
                               //Operation picture
                Stream ms;
                byte[] picbyte = null;
                try
                {
                    if ((ms = this.openFileDialog1.OpenFile()) != null)
                    {
                        //MessageBox.Show("ok");
                        picbyte = new byte[ms.Length];
                        ms.Position = 0;
                        ms.Read(picbyte, 0, Convert.ToInt32(ms.Length));

                    }
                }
                catch {picbyte=new byte[10];}

                cmd.Parameters.AddWithValue("@photo", picbyte);
              

                if (cmd.ExecuteNonQuery() == 1)
                    result = true;
                con.Close();
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-16 14:45:01
| Show all posts
I don’t know how you saved the pictures in the database. If you save it in a path, you can just read it directly, just use the dataset to read it directly.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-10-16 15:00:01
| Show all posts
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
dim MyConnection As OleDbConnection

Sub Page_Load(s As Object, E As EventArgs)
     MyConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath(".")+"/db/kk.mdb")
        If Not (IsPostBack) then
        BindDataGrid()
        End If
End Sub

Sub BindDataGrid()
    dim dadTitles as OleDbDataAdapter
    dim dstTitles as DataSet
    dadTitles=new OleDbDataAdapter("select * from [imgs] order by id desc",MyConnection)
dstTitles=new DataSet
dadTitles.fill(dstTitles)
MyDataGrid.DataSource=dstTitles
MyDataGrid.DataBind()
End Sub

Sub Mydatagrid_PageIndexChanged(s as object,e as DataGridPageChangedEventargs)
    MyDataGrid.CurrentPageIndex=e.newPageIndex
BindDataGrid()
End Sub

Function FormatURL(strArgument) as String
      Return ("RetrieveImgByDataGrid_SelectImg.aspx?id="&strArgument)
End Function

</script>
<html>
<head><title>DataGrid_CheckBox.aspx</title></head>
<body>
<B><A HREF="insertimgtodatabase.aspx">Insert Img To DataBase</A></B>
<form runat="server">
<asp:DataGrid id="MyDataGrid"
              width="300"
              Runat="server"
              AllowPaging="true"
pageSize="5"
OnPageIndexChanged="Mydatagrid_PageIndexChanged"
cellPadding="3"
AutoGenerateColumns="false"
HeaderStyle-BackColor="#ff0000"
HeaderStyle-Font-Bold="True"
HeaderStyle-Font-Name="Verdana"
HeaderStyle-Font-Size="13px"
HeaderStyle-ForeColor="#ffffff"
ItemStyle-BackColor=Beige
ItemStyle-Font-Name="verdana"
ItemStyle-Font-Size="13px"
>
              <PagerStyle Mode="NumericPages"
Font-Bold="true"
BackColor="#FFCC99"
HorizontalAlign="right"
>
</PagerStyle>
     <Columns>
<asp:TemplateColumn HeaderText="ID">
<ItemTemplate>
<asp:Label ID="lblID" Text='<%# DataBinder.Eval(Container.DataItem, "id") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="NAME">
<ItemTemplate>
<asp:Label ID="lblName" Text='<%# DataBinder.Eval(Container.DataItem, "name") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Image">
            <ItemTemplate>
              <asp:Image Width="150" Height="125" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "ID")) %>' Runat=server />
            </ItemTemplate>
       </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="ShowImage_HyperLink">
            <ItemTemplate>
              <asp:HyperLink Width="150" Height="125" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "ID")) %>' NavigateUrl='<%# "RetrieveImgByDataGrid_SelectImg.aspx?id ="&DataBinder.Eval(Container.DataItem, "ID")%>' Runat="server" />
            </ItemTemplate>
       </asp:TemplateColumn>
  </Columns>
</asp:DataGrid>
</form>
</body>
</html>
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-16 15:15:02
| Show all posts
sqldatasource, gridview, detailview, just a few controls
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list