4 Replies - 2002 Views - Last Post: 24 August 2011 - 02:20 AM Rate Topic: *---- 1 Votes

#1 Vivek Gautam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 17-September 10

handler and image error in asp.net

Posted 22 August 2011 - 08:02 AM

<asp:GridView ID="GridView1" runat="server">
<Columns>

<asp:BoundField DataField="REgistration_number" ReadOnly="true" HeaderText="Image ID"/>

<asp:BoundField DataField="name" HeaderText="Name"/>

<asp:TemplateField HeaderText="Image View" ControlStyle-Width="100px" ControlStyle-Height="100px">

<ItemTemplate>

<asp:Image ID="Image" runat="server" ImageUrl='<%# "Handler.ashx?id=" + Eval("id") %>' />

</ItemTemplate>

</asp:TemplateField>

</Columns>



error message---DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'id'. i got this on image and handeler line..

Is This A Good Question/Topic? 0
  • +

Replies To: handler and image error in asp.net

#2 Nakor   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: handler and image error in asp.net

Posted 22 August 2011 - 04:51 PM

It's pretty straightforward. You're data source that you're using to load the data into the gridview does not have a property named 'id', therefore using Eval("id") will not work. We would probably need to see the code for where you're loading the datasource.
Was This Post Helpful? 1
  • +
  • -

#3 Vivek Gautam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 17-September 10

Re: handler and image error in asp.net

Posted 22 August 2011 - 09:57 PM

View PostNakor, on 23 August 2011 - 05:21 AM, said:

It's pretty straightforward. You're data source that you're using to load the data into the gridview does not have a property named 'id', therefore using Eval("id") will not work. We would probably need to see the code for where you're loading the datasource.



thnx mate...that was really helpful for me..now my whole code id working
Was This Post Helpful? 0
  • +
  • -

#4 Vivek Gautam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 17-September 10

Re: handler and image error in asp.net

Posted 23 August 2011 - 12:39 AM

Gridview
<asp:GridView ID="GridView1" runat="server" >
    <Columns >

               

                <asp:TemplateField HeaderText="Image View" ControlStyle-Width="100px" ControlStyle-Height="100px">

                    <ItemTemplate>

                        <asp:Image ID="Image" runat="server" ImageUrl='<%# "Handler.ashx?id=" + Eval("Registration_Number")  %>' />

                    </ItemTemplate>

                </asp:TemplateField>

            </Columns>

        </asp:GridView>




on button click

        Dim dt As New Data.DataTable()
        Dim q As String = "SELECT Registration_Number ,Name,course_code ,Total_fees ,registration_fees FROM admission_entry where registration_number='"& txtRn.text & "' "
' selecting particular data matching with text box data

        cn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=e:\online.mdb;jet oledb:database password=Godfather;")
        cn.Open()

        Try


          

            Dim oledbCmd As New OleDbCommand(q, cn)

            Dim ad As New OleDbDataAdapter(oledbCmd)



            ad.Fill(dt)

            If dt.Rows.Count > 0 Then


                GridView1.DataSource = dt


                GridView1.DataBind()



            End If
            cn.Close()




here is my handler code

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
                
        Dim id As String = context.Request.QueryString("id")
        'get the querystring value that was pass on the ImageURL (see GridView MarkUp in Page1.aspx)
        If id IsNot Nothing Then
            
            Dim memoryStream As New IO.MemoryStream()
            Dim q As String = "SELECT photo_uploading FROM admission_entry WHERE id = @id"

            cn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=e:\online.mdb;jet oledb:database password=Godfather;")
            cn.Open()

           
            Dim cmd As New OleDbCommand(q, cn)

            cmd.Parameters.AddWithValue("@id", id)

         
            Dim reader As OleDbDataReader = cmd.ExecuteReader()

            reader.Read()

            Dim file As Byte() = DirectCast(reader("photo_uploading"), Byte())



            reader.Close()

            cn.Close()

            memoryStream.Write(file, 0, file.Length)
            context.Response.Buffer = True

            context.Response.BinaryWrite(file)

            memoryStream.Dispose()
        End If

            
        
    End Sub





problem is that im getting particular data with condition but getting same photo every time...
Was This Post Helpful? 0
  • +
  • -

#5 Vivek Gautam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 17-September 10

Re: handler and image error in asp.net

Posted 24 August 2011 - 02:20 AM

I got my mistake..it was in query string of handler where

Dim q As String = "SELECT photo_uploading FROM admission_entry WHERE id = @id"
i was using ID in stead of my database field name
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1