GridView顯示服務(wù)器圖片(保存為圖片路徑)_.Net教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:解讀ASP.NET密碼強(qiáng)度驗(yàn)證代碼實(shí)例效果如下: 輸入密碼: 密碼強(qiáng)度: 弱 中 強(qiáng) 代碼如下: %@PageLanguage=C#AutoEventWireup=trueCodeFile=Default.aspx.csInherits=_Default% EhtmlPUBLIC-//W3C//DTDXHTML1.0xhtml1-trans
//前臺(tái)頁(yè)面創(chuàng)建顯示圖片列 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> <asp:TemplateField headertext="顯示圖片"> <ItemTemplate> <asp:Image ID="img" Height="20" Width="20" ImageURL=’<%# GetImg(Eval("表中列名").ToString())%>’ runat="server" /> (注:后臺(tái)方法名用來(lái)得到服務(wù)器中全路徑) </ItemTemplate> <FooterStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle Width="20%" /> </asp:TemplateField> 或者2: <asp:TemplateField> <HeaderTemplate> 顯示圖片 </HeaderTemplate> <ItemTemplate> <a href="<%#GetImagePath()+Convert.ToString(Eval("表中列名"))%>" target="_blank"><img src="<%#GetImagePath()+Convert.ToString(Eval("表中列名"))%>" alt="" width="20px" height="20px" /></a> </ItemTemplate> <FooterStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle Width="10%" /> </asp:TemplateField> </asp:GridView> |
后臺(tái)代碼:
//獲取圖片
protected string GetImg(string img)
{
string imgurl = ImageURL + img; 注:ImageURL為服務(wù)器保存圖片文件夾的路徑
return imgurl;
}
public static string ImageURL {
get {
string imageurl = ConfigurationManager.AppSettings["ImageURL"].ToString()+"/";
if (imageurl != null) {
return imageurl;
}
return "";
}
}
或者2(顯示的圖片點(diǎn)擊可鏈接到對(duì)應(yīng)的圖片地址):
public static string GetImagePath()
{
return ConfigurationManager.AppSettings["ImageUrl"].ToString();
}
分享:解讀asp.net點(diǎn)擊textbox自動(dòng)清除其中文字在cs后臺(tái)代碼中直接添加: protectedvoidPage_Load(objectsender,EventArgse) { TextBox1.Attributes.Add(OnClick,this.value=\\);...
相關(guān).Net教程:
- asp.net如何得到GRIDVIEW中某行某列值的方法
- .net SMTP發(fā)送Email實(shí)例(可帶附件)
- js實(shí)現(xiàn)廣告漂浮效果的小例子
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)
- Asp.Net 無(wú)刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
- Asp.net獲取客戶端IP常見(jiàn)代碼存在的偽造IP問(wèn)題探討
- VS2010 水晶報(bào)表的使用方法
- ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
- asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼
- DataGridView - DataGridViewCheckBoxCell的使用介紹
- asp.net中javascript的引用(直接引入和間接引入)
- 三層+存儲(chǔ)過(guò)程實(shí)現(xiàn)分頁(yè)示例代碼
- 相關(guān)鏈接:
- 教程說(shuō)明:
.Net教程-GridView顯示服務(wù)器圖片(保存為圖片路徑)。