图像绑定到文字 [英] Image Binding to a Literal

查看:90
本文介绍了图像绑定到文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道我们是否可以将图像/图像绑定到文字控制中,如果是,是否有人可以向我展示一些示例或链接以实现该目的?



谢谢,

Chetan。

解决方案

你不能真的, Literal 只是将文本输出到HTML表单。您可以使用它来创建带路径的图像控件,但有更好的方法,例如 Image Web控件或HTML img标记。

你可以使用绑定你的图像的数据绑定功能,例如



DataTable dt = new DataTable();

if(dt.rows.count> 0)

{

for(int i = 0; i< = dt.rows.count -1; i ++ )

{

}

}


你可以使用数据绑定功能绑定例如你的形象



 DataTable dt = new DataTable(); 
if(dt.rows.count> 0)
{
for(int i = 0; i< = dt.rows.count -1; i ++)
{
< img src \images / \+ dt.rows [i] [Pic]。ToString()+/>;
}
}


Hi,
I want to know can we bind an Image/Images to a Literal Control, If Yes can anyone show me some examples or links on hoe to achieve that?

Thanks,
Chetan.

解决方案

You can't really, the Literal just pumps out text to the HTML form. You could use it to create an image control with a path, but there are better ways of doing that, such as the Image web control or the HTML img tag.


u can use a data binding function binding your image for example

DataTable dt = new DataTable();
if(dt.rows.count > 0)
{
for (int i = 0 ; i <=dt.rows.count -1 ; i++)
{
}
}


u can use a data binding function binding your image for example

DataTable dt = new DataTable();
if(dt.rows.count > 0)
{
   for (int i = 0 ; i <=dt.rows.count -1 ; i++)
  {
       <img src\"images/\" + dt.rows[i]["Pic"].ToString()+ "/>";
   }
}


这篇关于图像绑定到文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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