提出与gridview控件有关的问题 [英] asking a question related to gridview control

查看:85
本文介绍了提出与gridview控件有关的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在网格视图中显示图像,该图像的路径存储在数据库中

how to display image in gridview whose path stored in database

推荐答案

在网格视图中获取图像控件,以这种方式分配imageurl属性

take image control in grid view assign the imageurl property like this

<asp:GridView ID="GridView1" runat="server" >
           <Columns>
               <asp:TemplateField>
                   <ItemTemplate>
                   <asp:Image ID="img1" runat="server" ImageUrl='<%#Eval("Image path") %>' />
                   </ItemTemplate>
               </asp:TemplateField>
           </Columns>
       </asp:GridView>


尝试这篇不错的文章
Gridview图像
try this nice article
Gridview image


它是基于窗口的还是基于Web的(ASP.NET )?
考虑到它是winform.这是解决方案.

1.在DataGridView中添加一个DataGridViewImageColumn.
2.将列的Image属性设置为所需的图像.
3.处理DataGridView的Row Transactions事件,并在事件处理程序中添加以下代码:

is it windowBased or webbased(ASP.NET) ?
conside it is winform. here is solution.

1. Add a DataGridViewImageColumn in DataGridView.
2. Set the Image property of the column to image u want.
3. Handle the RowsAdded event of the DataGridView and add the following code in the event handler:

void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
    this.dataGridView1.Rows[e.RowIndex-1].Cells[0].Value = null;
}


这篇关于提出与gridview控件有关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆