不在数据库中将图像添加到ASP.NET GridView [英] Add Image to ASP.NET GridView not from Database

查看:67
本文介绍了不在数据库中将图像添加到ASP.NET GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个图像上传"控件和标题文本框以及一个添加按钮.
当我单击添加按钮图像和标题添加到gridview时.通过将图像和标题添加到gridview没有限制.

请帮帮我.

Hi guys,

I have a Image Upload control and caption textbox and an add button.
When I click the add button image and caption added to the gridview. There is no limit by adding the image and caption to the gridview.

Please help me.

推荐答案

那有什么大不了的.以2个模板"列作为网格视图.首先带标签,其他带图像控件.

在添加按钮上单击否,您会将图像保存在某个位置.之后,将Caption和Image URL存储在某些数据表或任何集合中,并将其绑定到网格.

应当就是这样.
So whats the big deal. Take a grid view with 2 Template columns. First with label and other with Image control.

No at the add button click you will save the image some where. After that store the Caption and Image URL in some data table or any collection and bind it to the grid.

That should be it.


涉及的步骤是

1)发布图像并将图像保存在静态字典中或保存到硬盘.静态字典会增加服务器内存的负载,但执行速度很快.硬盘方法稍慢一些,但没有内存压力.

2)创建一个http处理程序,该处理程序解析图像字节并将其发送到输出流.您发送给此处理程序的request参数应标识硬盘中的映像.

3)在网格视图的基础表中添加新行,其中一列表示为项目模板,其中包含图像.将新图像分配给新行中的该列索引,并将图像url设置为带有查询字符串参数的处理程序以标识该图像.

4)绑定gridview.

现在,您需要针对每个步骤使用Google进行搜索. 1)如何保存上传的图片2)如何创建自定义处理程序3)如何处理数据表5)如何在gridview中创建项目模板.

尝试!.如果卡住了,请发表您的查询.
The steps involved are

1) Post the image and keep the image in a static dictionary or save to hard disk. Static dictionary will increase the load in sever memory, but perform fast. The hard disk method little slower, but no memory pressure.

2) Create a http handler which parse the image bytes and send to the output stream. The request parameter you send to this handler should identify the image in the hard disk.

3) Add a new row in the underlying table for the gridview where a column represented as item template with a image in it. Assign a new image to that column index in the new row and set the image url to the handler with query string parameter to identify the image.

4) Bind the gridview.

Now you need to google for each step. 1) How to save an uploaded image 2)How to create a custom handler 3)How to handle a datatable 5) How to create item templates in gridview.

Try!. If stuck post your queries.


这篇关于不在数据库中将图像添加到ASP.NET GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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