binding second table's column's value to the gridview how?

Hi,

Im using stored procedure like this:

create proc selectimageandPosting 
@uName nvarchar(256) 
as 
begin 
select postingid,imageid,location, modelno, condition, description1,description2,years,months,days,price,negotiable,username,timeofposting from posting where username=@uName 
select imageurl from productimage where id=(select imageid from posting where username=@uName) 
end 

which gives me right o/p in query analyzer now in asp.net code behind i've written:

            con.Open()
            Dim cmd As New SqlCommand("selectimageandPosting", con)
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.Parameters.AddWithValue("@uName", User.Identity.Name)
            adat = New SqlDataAdapter(cmd)
            adat.Fill(ds)

            If ds.Tables(0).Rows.Count = 0 Or ds.Tables(1).Rows.Count = 0 Then
                lblID.Text = "NO Data"
                lblID.Visible = True

                'Label3.Text = "There are recently no records present in this category!!"
                'Label3.Font.Size = 20
                'Label3.ForeColor = Drawing.Color.Red
                'Label3.Visible = True
            Else
                gr.DataSource = ds
                gr.DataBind()
            End If
and using itemtemplates in gridview everything goes fine but im not able to bind the column imageurl with the imagecontrol in item template it gives me exception that no coumn exists with the name imageurl althought it exists in the second table which is their in the stored procedure .

 i've written following to bind imageurl column to the imagecontrol.

<asp:Image ID="imgBndProduct" runat="server" Height="70px"
                                                                ImageUrl='<%#  Eval("imageurl") %>'
                                                                Style="border-style: solid; border-width: 1px; border-color: Gray"
                                                                Width="130px" />
                                                        </td>

 

please help me out. that how do i bind any column value from the second table's column present in dataset to the girdview

Thanks in advance!!!

0
Sangeeta
4/26/2009 1:46:31 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
933 Views

Similar Articles

[PageSpeed] 39

 Try using an Alias for you column let say   imageurl1

I suspect, there can be a problem due to ImageUrl property of asp:image


Engineer Wahab Hussain
Web Developer
Chillizone
http://www.linkedin.com/in/hellowahab
0
hellowahab
4/26/2009 3:35:52 PM

 thx but  it didnt solved my problme!!!

0
Sangeeta
4/28/2009 3:06:51 AM

 hey i got the solution for my problem here it is: we need to produce single result set using sql queries and it can b done as follows:

 

create proc seleceimageandposting

@uName varchar(256)

as 

begin

select posting.*, imageurl as imageurl1 from  posting left outer join productimage

on posting.imageid= productimage.id where username=@uname

end

 

and thts it ... and im done with this..

0
Sangeeta
4/28/2009 3:16:42 AM
Reply: