ASP.NET Image Upload... Guru needed

Discussion in 'ASP .Net' started by John Thompson, Jun 30, 2004.

  1. We're sooo close. When we load the page to upload the image, all of
    the prms go through except the binary image data. Using SQL server
    with the data type set to "image".

    Please help!

    Thanks-

    John





    <%@ Page Language="vb" debug="true"%>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Configuration" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.IO" %>
    <Script Language="VB" runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    If Not Page.IsPostBack Then
    populatelist()
    end if

    End Sub

    sub PopulateList()
    Dim dt As DataTable
    Dim dr As DataRow
    dt = New DataTable

    dt.Columns.Add(New DataColumn("id", GetType(Integer)))
    dt.Columns.Add(New DataColumn("f_name", GetType(String)))
    dt.Columns.Add(New DataColumn("l_name", GetType(String)))
    dt.Columns.Add(New DataColumn("ima_type", GetType(String)))
    dt.Columns.Add(New DataColumn("ima_length", GetType(Integer)))
    dt.Columns.Add(New DataColumn("notoryes", GetType(String)))

    'Server=216.51.xxx.x;UID=c2611;Pwd=managment;Database=SQLDB988;
    'Dim MyC7 As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    Dim MyC7 As New SqlConnection("Data Source=216.51.xxx.x;" _
    & "Initial
    Catalog=SQLDB988;User

    Id=c2611;Password=management;" _
    & "Connect
    Timeout=15;Network Library=dbmssocn;")
    Dim MySQL2 as string = "Select * from imaandname order by id desc"
    MYC7.Open()
    Dim cmd7 As SqlCommand = new sqlcommand(MySQL2,MYC7)
    Dim Reader7 As SqlDataReader = cmd7.ExecuteReader()
    while Reader7.read()
    dr = dt.NewRow()

    dr(0) = Reader7("id")
    dr(1) = Reader7("f_name")
    dr(2) = Reader7("l_name")
    dr(3) = Reader7("ima_type")
    dr(4) = Reader7("ima_length")

    if Reader7("ima_length") = 0 then
    dr(5) = "NoImage.png"
    else
    dr(5) = "readimage.aspx?id=" & Reader7("id")
    end if

    dt.Rows.Add(dr)

    end while

    Reader7.close()
    MYC7.close()

    dlCategories7.DataSource = new DataView(dt)
    dlCategories7.DataBind

    Response.Write("tst1")

    End Sub



    Public Sub Add_New_Picture(sender As Object, e As EventArgs)



    Dim Size As Int64
    Dim ImageType As String
    Dim ImageStream As Stream

    Size = c_pic.PostedFile.ContentLength
    ImageType = c_pic.PostedFile.ContentType
    ImageStream = c_pic.PostedFile.InputStream

    if Size >100000 then
    response.write("sorry your image exceed 0.1 MB, your uploads activate
    a response end in script.<br>TRY AGAIN

    with a smaller image.")
    response.end
    end if


    ' this is where its failing
    Dim ImageContent(Size) As Byte
    Dim intStatus As Integer
    intStatus = ImageStream.Read(ImageContent, 0, Size)
    Response.Write("Blowme")

    Dim myConnection2 As New SqlConnection("Data Source=216.51.xxx.x;" _
    & "Initial
    Catalog=SQLDB988;User

    Id=c2611;Password=management;" _
    & "Connect
    Timeout=15;Network Library=dbmssocn;")
    Dim myCommand2 As New SqlCommand("Insert into imaandname
    (f_name,l_name,ima,ima_length,ima_type) VALUES

    (@f_name,@l_name,@ima,@ima_length,@ima_type)", myConnection2)

    Dim f_name As New SqlParameter("@f_name", SqlDbType.VarChar, 50)
    f_name.Value = f_name_t.Text
    myCommand2.Parameters.Add(f_name)

    Dim l_name As New SqlParameter("@l_name", SqlDbType.VarChar, 50)
    l_name.Value = l_name_t.Text
    myCommand2.Parameters.Add(l_name)

    Dim ima_type As New SqlParameter("@ima_type", SqlDbType.VarChar, 50)
    if ImageType = "image/pjpeg" or ImageType = "image/gif" or ImageType =
    "image/png" then
    ima_type.Value = ImageType
    else
    ima_type.Value = ""
    end if
    myCommand2.Parameters.Add(ima_type)

    Dim prmPersonImage As New SqlParameter("@ima", SqlDbType.Image)
    prmPersonImage.Value = ImageContent
    myCommand2.Parameters.Add(prmPersonImage)
    Response.Write("tst2")

    Dim ima_length As New SqlParameter("@ima_length", SqlDbType.int)
    ima_length.Value = Size
    myCommand2.Parameters.Add(ima_length)



    Try
    myConnection2.Open()
    myCommand2.ExecuteNonQuery()
    myConnection2.Close()
    Response.Write("New image successfully added!")
    Catch SQLexc As SqlException
    Response.Write("Insert Failed. Error Details are: " &
    SQLexc.ToString())
    End Try

    response.redirect("testy.aspx")

    End Sub

    Public Sub dlcategories7_Cancel(sender As Object, e As
    DataGridCommandEventArgs)
    dlcategories7.EditItemIndex = -1
    populatelist()
    End Sub

    Public Sub dlcategories7_Edit(sender As Object, e As
    DataGridCommandEventArgs)
    dlcategories7.EditItemIndex = e.Item.ItemIndex
    populatelist()
    End Sub

    Public Sub dlcategories7_Update(sender As Object, e As
    DataGridCommandEventArgs)

    Dim strConn As New SqlConnection("Data Source=216.51.xxx.x;" _
    & "Initial
    Catalog=SQLDB988;User

    Id=c2611;Password=management;" _
    & "Connect
    Timeout=15;Network Library=dbmssocn;")

    Dim MyCommand As SqlCommand
    Dim e_f_name As textbox = E.Item.cells(1).Controls(1)
    Dim e_l_name As textbox = E.Item.cells(2).Controls(1)
    Dim e_d_pic As object = E.Item.cells(5).Controls(1)

    Dim intImageS As Int64
    Dim strImageT As String
    Dim ImageStream2 As Stream


    intImageS = e_d_pic.PostedFile.ContentLength
    strImageT = e_d_pic.PostedFile.ContentType
    ImageStream2 = e_d_pic.PostedFile.InputStream

    if intImageS >100000 then
    response.write("sorry your image exceed 0.1 MB, your uploads activate
    a response end in script.<br>TRY AGAIN

    with a smaller image.")
    response.end
    end if

    Dim ImageContent2(intImageS) As Byte
    Dim intStatus2 As Integer
    intStatus2 = ImageStream2.Read(ImageContent2, 0, intImageS)

    Dim strEdit As String
    if strImageT = "image/pjpeg" or strImageT = "image/gif" or strImageT
    = "image/png" then
    strEdit =" UPDATE imaandname SET" & _
    " f_name =@f_name, l_name =@l_name, " & _
    " ima_length=@ima_length, ima_type=@ima_type, " & _
    " ima=@ima " & _
    " WHERE iD = @ID"
    else
    strEdit =" UPDATE imaandname SET" & _
    " f_name =@f_name, l_name =@l_name WHERE iD = @ID"
    end if

    MyCommand = New SqlCommand(strEdit, strconn)
    MyCommand.Parameters.Add(New SQLParameter("@f_name", e_f_name.text))
    MyCommand.Parameters.Add(New SQLParameter("@l_name", e_l_name.text))
    MyCommand.Parameters.Add(New SQLParameter("@ima_length", intImageS ))
    MyCommand.Parameters.Add(New SQLParameter("@ima_type", strImageT ))
    MyCommand.Parameters.Add(New SQLParameter("@ima", ImageContent2 ))
    MyCommand.Parameters.Add(New SQLParameter("@ID",
    dlCategories7.DataKeys(CInt(E.Item.ItemIndex)) ))
    strconn.Open()
    MyCommand.ExecuteNonQuery()
    dlcategories7.EditItemIndex = -1
    strconn.close

    populatelist()
    end sub




    Public Sub dlcategories7_Delete(sender As Object, e As
    DataGridCommandEventArgs)

    Dim conn As New SqlConnection("Data Source=216.51.xxx.x;" _
    & "Initial
    Catalog=SQLDB988;User

    Id=c2611;Password=management;" _
    & "Connect
    Timeout=15;Network Library=dbmssocn;")
    Dim cmd As SqlCommand
    conn.Open()
    cmd = New SqlCommand()
    Dim id As string
    id = dlcategories7.DataKeys(CInt(E.Item.ItemIndex))
    cmd.CommandText = "Delete from imaandname where id="&id
    cmd.Connection = conn
    cmd.ExecuteNonQuery()
    cmd.connection.close
    dlcategories7.EditItemIndex = -1
    populatelist()

    End Sub

    Public Sub deleteonlyimage(sender As Object, e As EventArgs)
    Dim strID As string =
    dlcategories7.DataKeys(dlcategories7.SelectedItem.ItemIndex)
    Dim conn37 As New SqlConnection("Data Source=216.51.xxx.x;" _
    & "Initial
    Catalog=SQLDB988;User

    Id=c2611;Password=management;" _
    & "Connect
    Timeout=15;Network Library=dbmssocn;")
    Dim cmd37 As SqlCommand
    conn37.Open()
    cmd37 = New SqlCommand()
    cmd37.CommandText = "update imaandname set ima_type=' ', ima_length=0
    where id="&strID
    cmd37.Connection = conn37
    cmd37.ExecuteNonQuery()
    cmd37.connection.close
    response.write(id)
    dlcategories7.EditItemIndex = -1
    populatelist()
    end sub
    </SCRIPT>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Datagrid in-place editing w/images. Sagasnet
    webstudio.</title>
    </head>

    <body>
    <form runat="Server" ENCTYPE="multipart/form-data" METHOD="POST">
    <table style="border:1pt #4B4D67
    solid;font-family:arial;font-size:8pt;">
    <tr>
    <td>
    Upload New Image<br>
    <INPUT TYPE="FILE" ID="c_pic" style="border:1pt #4B4D67
    solid;font-family:arial;font-size:8pt;" runat="server"

    /><br>
    First Name.<br>
    <asp:textbox Id="f_name_t" style="border:1pt #4B4D67
    solid;font-family:arial;font-size:8pt;" runat="server"

    /><br>
    Last Name.<br>
    <asp:textbox Id="l_name_t" style="border:1pt #4B4D67
    solid;font-family:arial;font-size:8pt;" runat="server"

    /><br>
    <asp:Button Text="Upload New Picture" OnClick="Add_New_Picture"
    style="border:1pt #4B4D67

    solid;font-family:arial;font-size:8pt;" runat="server" />
    </td>
    </tr>
    </table>
    <hr>
    <asp:datagrid
    id="dlcategories7"
    AutoGenerateColumns="False"
    OnSelectedIndexChanged="deleteonlyimage"
    OnDeleteCommand="dlCategories7_Delete"
    OnEditCommand="dlCategories7_Edit"
    OnCancelCommand="dlCategories7_Cancel"
    OnUpdateCommand="dlCategories7_Update"
    DataKeyField="id"
    CellPadding="1"
    Itemstyle-VerticalAlign="TOP"
    font-name="Arial"
    font-size="9pt"
    HeaderStyle-BackColor="#aaaadd"
    runat="server">
    <Columns>
    <asp:BoundColumn DataField="ID" readonly="true"
    HeaderText="ID"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="FIRST NAME">
    <ItemTemplate>
    <asp:label id="f_name" text='<%# DataBinder.Eval(Container.DataItem,
    "f_name") %>' runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
    <asp:textbox width="70" ID="e_f_name" text='<%#
    DataBinder.Eval(Container.DataItem, "f_name") %>'

    style="border:1pt #4B4D67 solid;font-family:arial;font-size:8pt;"
    runat="server" />
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="LAST NAME">
    <ItemTemplate>
    <asp:label id="l_name" text='<%# DataBinder.Eval(Container.DataItem,
    "l_name") %>' runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
    <asp:textbox width="70" ID="e_l_name" text='<%#
    DataBinder.Eval(Container.DataItem, "l_name") %>'

    style="border:1pt #4B4D67 solid;font-family:arial;font-size:8pt;"
    runat="server" />
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="ima_length" readonly="true"
    HeaderText="IMG-KB"></asp:BoundColumn>
    <asp:BoundColumn DataField="ima_type" readonly="true"
    HeaderText="IMG-TYPE"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="IMAGE">
    <ItemTemplate>
    <asp:Image Width="90" Height="60" ImageUrl='<%#
    DataBinder.Eval(Container.DataItem, "Notoryes") %>'

    Runat=server />
    </ItemTemplate>
    <EditItemTemplate>
    <INPUT TYPE="FILE" width="70" ID="e_d_pic" style="border:1pt #4B4D67
    solid;font-family:arial;font-size:8pt;"

    runat="server" /><br>
    Don't select,<br>to keep orginal image.<br>or<br>
    <asp:linkbutton runat="server" text="Del only Image"
    CommandName="Select" />
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:ButtonColumn HeaderText="DEL" Text="Delete" CommandName="Delete"
    runat="server" />
    <asp:editcommandcolumn HeaderText="EDIT" edittext="Edit"
    canceltext="Cancel" updatetext="Update"

    itemstyle-wrap="false"/>
    </columns>
    </asp:datagrid>
    </form>

    Upload blobs limited to 0.1 MB and gif, jpg and png.<br>
    <a href='#' onClick='window.close()'>closewindow</a><br>
    </body>
    </html>
     
    John Thompson, Jun 30, 2004
    #1
    1. Advertising

  2. This article provides a working example for you:
    http://steve.orr.net/content/asp200307so_f.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "John Thompson" <> wrote in message
    news:...
    > We're sooo close. When we load the page to upload the image, all of
    > the prms go through except the binary image data. Using SQL server
    > with the data type set to "image".
    >
    > Please help!
    >
    > Thanks-
    >
    > John
    >
    >
    >
    >
    >
    > <%@ Page Language="vb" debug="true"%>
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Configuration" %>
    > <%@ Import Namespace="System.Data.SqlClient" %>
    > <%@ Import Namespace="System.IO" %>
    > <Script Language="VB" runat="server">
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    >
    > If Not Page.IsPostBack Then
    > populatelist()
    > end if
    >
    > End Sub
    >
    > sub PopulateList()
    > Dim dt As DataTable
    > Dim dr As DataRow
    > dt = New DataTable
    >
    > dt.Columns.Add(New DataColumn("id", GetType(Integer)))
    > dt.Columns.Add(New DataColumn("f_name", GetType(String)))
    > dt.Columns.Add(New DataColumn("l_name", GetType(String)))
    > dt.Columns.Add(New DataColumn("ima_type", GetType(String)))
    > dt.Columns.Add(New DataColumn("ima_length", GetType(Integer)))
    > dt.Columns.Add(New DataColumn("notoryes", GetType(String)))
    >
    > 'Server=216.51.xxx.x;UID=c2611;Pwd=managment;Database=SQLDB988;
    > 'Dim MyC7 As New

    SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    > Dim MyC7 As New SqlConnection("Data Source=216.51.xxx.x;" _
    > & "Initial
    > Catalog=SQLDB988;User
    >
    > Id=c2611;Password=management;" _
    > & "Connect
    > Timeout=15;Network Library=dbmssocn;")
    > Dim MySQL2 as string = "Select * from imaandname order by id desc"
    > MYC7.Open()
    > Dim cmd7 As SqlCommand = new sqlcommand(MySQL2,MYC7)
    > Dim Reader7 As SqlDataReader = cmd7.ExecuteReader()
    > while Reader7.read()
    > dr = dt.NewRow()
    >
    > dr(0) = Reader7("id")
    > dr(1) = Reader7("f_name")
    > dr(2) = Reader7("l_name")
    > dr(3) = Reader7("ima_type")
    > dr(4) = Reader7("ima_length")
    >
    > if Reader7("ima_length") = 0 then
    > dr(5) = "NoImage.png"
    > else
    > dr(5) = "readimage.aspx?id=" & Reader7("id")
    > end if
    >
    > dt.Rows.Add(dr)
    >
    > end while
    >
    > Reader7.close()
    > MYC7.close()
    >
    > dlCategories7.DataSource = new DataView(dt)
    > dlCategories7.DataBind
    >
    > Response.Write("tst1")
    >
    > End Sub
    >
    >
    >
    > Public Sub Add_New_Picture(sender As Object, e As EventArgs)
    >
    >
    >
    > Dim Size As Int64
    > Dim ImageType As String
    > Dim ImageStream As Stream
    >
    > Size = c_pic.PostedFile.ContentLength
    > ImageType = c_pic.PostedFile.ContentType
    > ImageStream = c_pic.PostedFile.InputStream
    >
    > if Size >100000 then
    > response.write("sorry your image exceed 0.1 MB, your uploads activate
    > a response end in script.<br>TRY AGAIN
    >
    > with a smaller image.")
    > response.end
    > end if
    >
    >
    > ' this is where its failing
    > Dim ImageContent(Size) As Byte
    > Dim intStatus As Integer
    > intStatus = ImageStream.Read(ImageContent, 0, Size)
    > Response.Write("Blowme")
    >
    > Dim myConnection2 As New SqlConnection("Data Source=216.51.xxx.x;" _
    > & "Initial
    > Catalog=SQLDB988;User
    >
    > Id=c2611;Password=management;" _
    > & "Connect
    > Timeout=15;Network Library=dbmssocn;")
    > Dim myCommand2 As New SqlCommand("Insert into imaandname
    > (f_name,l_name,ima,ima_length,ima_type) VALUES
    >
    > (@f_name,@l_name,@ima,@ima_length,@ima_type)", myConnection2)
    >
    > Dim f_name As New SqlParameter("@f_name", SqlDbType.VarChar, 50)
    > f_name.Value = f_name_t.Text
    > myCommand2.Parameters.Add(f_name)
    >
    > Dim l_name As New SqlParameter("@l_name", SqlDbType.VarChar, 50)
    > l_name.Value = l_name_t.Text
    > myCommand2.Parameters.Add(l_name)
    >
    > Dim ima_type As New SqlParameter("@ima_type", SqlDbType.VarChar, 50)
    > if ImageType = "image/pjpeg" or ImageType = "image/gif" or ImageType =
    > "image/png" then
    > ima_type.Value = ImageType
    > else
    > ima_type.Value = ""
    > end if
    > myCommand2.Parameters.Add(ima_type)
    >
    > Dim prmPersonImage As New SqlParameter("@ima", SqlDbType.Image)
    > prmPersonImage.Value = ImageContent
    > myCommand2.Parameters.Add(prmPersonImage)
    > Response.Write("tst2")
    >
    > Dim ima_length As New SqlParameter("@ima_length", SqlDbType.int)
    > ima_length.Value = Size
    > myCommand2.Parameters.Add(ima_length)
    >
    >
    >
    > Try
    > myConnection2.Open()
    > myCommand2.ExecuteNonQuery()
    > myConnection2.Close()
    > Response.Write("New image successfully added!")
    > Catch SQLexc As SqlException
    > Response.Write("Insert Failed. Error Details are: " &
    > SQLexc.ToString())
    > End Try
    >
    > response.redirect("testy.aspx")
    >
    > End Sub
    >
    > Public Sub dlcategories7_Cancel(sender As Object, e As
    > DataGridCommandEventArgs)
    > dlcategories7.EditItemIndex = -1
    > populatelist()
    > End Sub
    >
    > Public Sub dlcategories7_Edit(sender As Object, e As
    > DataGridCommandEventArgs)
    > dlcategories7.EditItemIndex = e.Item.ItemIndex
    > populatelist()
    > End Sub
    >
    > Public Sub dlcategories7_Update(sender As Object, e As
    > DataGridCommandEventArgs)
    >
    > Dim strConn As New SqlConnection("Data Source=216.51.xxx.x;" _
    > & "Initial
    > Catalog=SQLDB988;User
    >
    > Id=c2611;Password=management;" _
    > & "Connect
    > Timeout=15;Network Library=dbmssocn;")
    >
    > Dim MyCommand As SqlCommand
    > Dim e_f_name As textbox = E.Item.cells(1).Controls(1)
    > Dim e_l_name As textbox = E.Item.cells(2).Controls(1)
    > Dim e_d_pic As object = E.Item.cells(5).Controls(1)
    >
    > Dim intImageS As Int64
    > Dim strImageT As String
    > Dim ImageStream2 As Stream
    >
    >
    > intImageS = e_d_pic.PostedFile.ContentLength
    > strImageT = e_d_pic.PostedFile.ContentType
    > ImageStream2 = e_d_pic.PostedFile.InputStream
    >
    > if intImageS >100000 then
    > response.write("sorry your image exceed 0.1 MB, your uploads activate
    > a response end in script.<br>TRY AGAIN
    >
    > with a smaller image.")
    > response.end
    > end if
    >
    > Dim ImageContent2(intImageS) As Byte
    > Dim intStatus2 As Integer
    > intStatus2 = ImageStream2.Read(ImageContent2, 0, intImageS)
    >
    > Dim strEdit As String
    > if strImageT = "image/pjpeg" or strImageT = "image/gif" or strImageT
    > = "image/png" then
    > strEdit =" UPDATE imaandname SET" & _
    > " f_name =@f_name, l_name =@l_name, " & _
    > " ima_length=@ima_length, ima_type=@ima_type, " & _
    > " ima=@ima " & _
    > " WHERE iD = @ID"
    > else
    > strEdit =" UPDATE imaandname SET" & _
    > " f_name =@f_name, l_name =@l_name WHERE iD = @ID"
    > end if
    >
    > MyCommand = New SqlCommand(strEdit, strconn)
    > MyCommand.Parameters.Add(New SQLParameter("@f_name", e_f_name.text))
    > MyCommand.Parameters.Add(New SQLParameter("@l_name", e_l_name.text))
    > MyCommand.Parameters.Add(New SQLParameter("@ima_length", intImageS ))
    > MyCommand.Parameters.Add(New SQLParameter("@ima_type", strImageT ))
    > MyCommand.Parameters.Add(New SQLParameter("@ima", ImageContent2 ))
    > MyCommand.Parameters.Add(New SQLParameter("@ID",
    > dlCategories7.DataKeys(CInt(E.Item.ItemIndex)) ))
    > strconn.Open()
    > MyCommand.ExecuteNonQuery()
    > dlcategories7.EditItemIndex = -1
    > strconn.close
    >
    > populatelist()
    > end sub
    >
    >
    >
    >
    > Public Sub dlcategories7_Delete(sender As Object, e As
    > DataGridCommandEventArgs)
    >
    > Dim conn As New SqlConnection("Data Source=216.51.xxx.x;" _
    > & "Initial
    > Catalog=SQLDB988;User
    >
    > Id=c2611;Password=management;" _
    > & "Connect
    > Timeout=15;Network Library=dbmssocn;")
    > Dim cmd As SqlCommand
    > conn.Open()
    > cmd = New SqlCommand()
    > Dim id As string
    > id = dlcategories7.DataKeys(CInt(E.Item.ItemIndex))
    > cmd.CommandText = "Delete from imaandname where id="&id
    > cmd.Connection = conn
    > cmd.ExecuteNonQuery()
    > cmd.connection.close
    > dlcategories7.EditItemIndex = -1
    > populatelist()
    >
    > End Sub
    >
    > Public Sub deleteonlyimage(sender As Object, e As EventArgs)
    > Dim strID As string =
    > dlcategories7.DataKeys(dlcategories7.SelectedItem.ItemIndex)
    > Dim conn37 As New SqlConnection("Data Source=216.51.xxx.x;" _
    > & "Initial
    > Catalog=SQLDB988;User
    >
    > Id=c2611;Password=management;" _
    > & "Connect
    > Timeout=15;Network Library=dbmssocn;")
    > Dim cmd37 As SqlCommand
    > conn37.Open()
    > cmd37 = New SqlCommand()
    > cmd37.CommandText = "update imaandname set ima_type=' ', ima_length=0
    > where id="&strID
    > cmd37.Connection = conn37
    > cmd37.ExecuteNonQuery()
    > cmd37.connection.close
    > response.write(id)
    > dlcategories7.EditItemIndex = -1
    > populatelist()
    > end sub
    > </SCRIPT>
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    >
    > <html>
    > <head>
    > <title>Datagrid in-place editing w/images. Sagasnet
    > webstudio.</title>
    > </head>
    >
    > <body>
    > <form runat="Server" ENCTYPE="multipart/form-data" METHOD="POST">
    > <table style="border:1pt #4B4D67
    > solid;font-family:arial;font-size:8pt;">
    > <tr>
    > <td>
    > Upload New Image<br>
    > <INPUT TYPE="FILE" ID="c_pic" style="border:1pt #4B4D67
    > solid;font-family:arial;font-size:8pt;" runat="server"
    >
    > /><br>
    > First Name.<br>
    > <asp:textbox Id="f_name_t" style="border:1pt #4B4D67
    > solid;font-family:arial;font-size:8pt;" runat="server"
    >
    > /><br>
    > Last Name.<br>
    > <asp:textbox Id="l_name_t" style="border:1pt #4B4D67
    > solid;font-family:arial;font-size:8pt;" runat="server"
    >
    > /><br>
    > <asp:Button Text="Upload New Picture" OnClick="Add_New_Picture"
    > style="border:1pt #4B4D67
    >
    > solid;font-family:arial;font-size:8pt;" runat="server" />
    > </td>
    > </tr>
    > </table>
    > <hr>
    > <asp:datagrid
    > id="dlcategories7"
    > AutoGenerateColumns="False"
    > OnSelectedIndexChanged="deleteonlyimage"
    > OnDeleteCommand="dlCategories7_Delete"
    > OnEditCommand="dlCategories7_Edit"
    > OnCancelCommand="dlCategories7_Cancel"
    > OnUpdateCommand="dlCategories7_Update"
    > DataKeyField="id"
    > CellPadding="1"
    > Itemstyle-VerticalAlign="TOP"
    > font-name="Arial"
    > font-size="9pt"
    > HeaderStyle-BackColor="#aaaadd"
    > runat="server">
    > <Columns>
    > <asp:BoundColumn DataField="ID" readonly="true"
    > HeaderText="ID"></asp:BoundColumn>
    > <asp:TemplateColumn HeaderText="FIRST NAME">
    > <ItemTemplate>
    > <asp:label id="f_name" text='<%# DataBinder.Eval(Container.DataItem,
    > "f_name") %>' runat="server" />
    > </ItemTemplate>
    > <EditItemTemplate>
    > <asp:textbox width="70" ID="e_f_name" text='<%#
    > DataBinder.Eval(Container.DataItem, "f_name") %>'
    >
    > style="border:1pt #4B4D67 solid;font-family:arial;font-size:8pt;"
    > runat="server" />
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="LAST NAME">
    > <ItemTemplate>
    > <asp:label id="l_name" text='<%# DataBinder.Eval(Container.DataItem,
    > "l_name") %>' runat="server" />
    > </ItemTemplate>
    > <EditItemTemplate>
    > <asp:textbox width="70" ID="e_l_name" text='<%#
    > DataBinder.Eval(Container.DataItem, "l_name") %>'
    >
    > style="border:1pt #4B4D67 solid;font-family:arial;font-size:8pt;"
    > runat="server" />
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > <asp:BoundColumn DataField="ima_length" readonly="true"
    > HeaderText="IMG-KB"></asp:BoundColumn>
    > <asp:BoundColumn DataField="ima_type" readonly="true"
    > HeaderText="IMG-TYPE"></asp:BoundColumn>
    > <asp:TemplateColumn HeaderText="IMAGE">
    > <ItemTemplate>
    > <asp:Image Width="90" Height="60" ImageUrl='<%#
    > DataBinder.Eval(Container.DataItem, "Notoryes") %>'
    >
    > Runat=server />
    > </ItemTemplate>
    > <EditItemTemplate>
    > <INPUT TYPE="FILE" width="70" ID="e_d_pic" style="border:1pt #4B4D67
    > solid;font-family:arial;font-size:8pt;"
    >
    > runat="server" /><br>
    > Don't select,<br>to keep orginal image.<br>or<br>
    > <asp:linkbutton runat="server" text="Del only Image"
    > CommandName="Select" />
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > <asp:ButtonColumn HeaderText="DEL" Text="Delete" CommandName="Delete"
    > runat="server" />
    > <asp:editcommandcolumn HeaderText="EDIT" edittext="Edit"
    > canceltext="Cancel" updatetext="Update"
    >
    > itemstyle-wrap="false"/>
    > </columns>
    > </asp:datagrid>
    > </form>
    >
    > Upload blobs limited to 0.1 MB and gif, jpg and png.<br>
    > <a href='#' onClick='window.close()'>closewindow</a><br>
    > </body>
    > </html>
     
    Steve C. Orr [MVP, MCSD], Jun 30, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Efy.
    Replies:
    2
    Views:
    1,099
  2. Joe

    Control Guru Needed

    Joe, Jan 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    367
  3. Andreas Klemt

    Regular Expressions Guru needed. Please help!

    Andreas Klemt, Aug 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    285
    Andreas Klemt
    Aug 18, 2004
  4. =?Utf-8?B?VGltOjouLg==?=

    Postback Probelm... GURU Needed...

    =?Utf-8?B?VGltOjouLg==?=, Jul 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    428
    Brock Allen
    Jul 28, 2005
  5. JimmySlam

    ASP Guru needed (XML-Flash+ASP)

    JimmySlam, Mar 15, 2006, in forum: ASP General
    Replies:
    9
    Views:
    178
    uhhjl
    Mar 21, 2006
Loading...

Share This Page