Image imgView = (Image)(e.Row.FindControl("imgViewIcon")); if (imgView != null) { imgView.ImageURL = Server.MapPath("/upload/icon.gif"); }
imgView.ImageURL = Server.MapPath("/upload/icon.gif");
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetPokemon.aspx.cs" Inherits="GetPokemon" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class GetPokemon : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BoundField Icon = new BoundField(); Icon.HeaderText = "Icon"; BoundField Code = new BoundField(); Code.HeaderText = "Code"; Code.DataField = "PokemonCode"; BoundField Name = new BoundField(); Name.HeaderText = "Pokemon"; Name.DataField = "PokemonName"; BoundField Pic = new BoundField(); Pic.HeaderText = "Picture"; GridView1.Columns.Add(Icon); GridView1.Columns.Add(Code); GridView1.Columns.Add(Name); GridView1.Columns.Add(Pic); } PokedexTable pokemon = new PokedexTable(); GridView1.AutoGenerateColumns = false; GridView1.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound); GridView1.DataSource = pokemon.GetAllPokedex(); GridView1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Image Icon = new Image(); Icon.ImageUrl = string.Format("~/PokemonImage.aspx?type=icon&code={0}", e.Row.Cells[1].Text); e.Row.Cells[0].Controls.Add(Icon); Image Pic = new Image(); Pic.ImageUrl = string.Format("~/PokemonImage.aspx?type=artwork&code={0}", e.Row.Cells[1].Text); e.Row.Cells[3].Controls.Add(Pic); } } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง