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); }
<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>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)