Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working with GridView in asp.net 3.5,i want to display the columns(Hotelimage,Address,URL)in my grid. For this i wrote the following code in my grdvHotels.aspx.cs file.

Page_Load
{
   grdvHotels.DataBind();
}
DataTable GetData()
{
          DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Hotel", typeof(string)));
            dt.Columns.Add(new DataColumn("Address", typeof(string)));
            dt.Columns.Add(new DataColumn("URL", typeof(string)));
 
          DataRow dr = dt.NewRow();
            dr["Hotel"] = ResolveUrl("~/IMAGES/image1.jpg");
            dr["Address"] = "Bangalore";
            dr["URL"] = ResolveUrl("www.yahoo.com");
            dt.Rows.Add(dr);
}


Source
XML
<asp:GridView ID="grdHotels" runat="server"
       CellSpacing="3" AutoGenerateColumns="False" DataSource='<%#GetData() %>'>
        <Columns>
           <asp:ImageField DataImageUrlField="HOTEL"></asp:ImageField>
            <asp:BoundField HeaderText="Address" DataField="Address" />
            <asp:BoundField HeaderText="URL" DataField="URL" />
        </Columns>
       <SelectedRowStyle ForeColor="White" Font-Bold="true" BackColor="Aqua" ></SelectedRowStyle>
    </asp:GridView>


------------------------------------------------------
While running the application error encountered. I didn't get the solution for this problem. Is anything required to add my code.Plz give the solution.

Thanks
Raj
Posted
Updated 5-Jul-11 0:47am
v2

1 solution

i think this link [^] will help you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900