我如何在我的网站中显示图像..表中的商店是否有类型Varchar(255)? [英] How I Can Display Image In My Website ..Store In Table Has Its Type Varchar(255) ?

查看:58
本文介绍了我如何在我的网站中显示图像..表中的商店是否有类型Varchar(255)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在资源管理器调试器中的代码(F12):

 <   tr  >  

< < span class =code-leadattribute> th rowspan =' 5' width =' 150px' > < img runat =' 服务器' src =' ../ pic / cs1.jpg' > < / th >
< th width =' 50px' > 名称:< / td >
< td > laptop < / td >
< / tr >










这是我的真实代码:



 private void fillpage()
{

ArrayList comuterlist = connectionclass.getcomputertype(!IsPostBack? %:DropDownList1.SelectedValue);
StringBuilder sb = new StringBuilder();
foreach(计算机列表中的计算机计算机)
{
sb.Append(
string.Format(
@< class =' computertable' >
< tr >

< th rowspan =' 5' width =' 150px' > < img < span class =code-attribute> runat =' 服务器' src =' {5}' > < / th >
< th width =' 50px' > 名称:< / td >
< td > {0} < / td >
< / tr >

< tr >

< th > 价格:< / th >
< td > {1} < / td >
< / tr >
< tr >

< th > 处理器:< / th >
< td > {2} < / td >
< / tr >
< tr & gt;

< th > Ram:< / th >
< td > {3} < / td >
< / tr < span class =code-keyword>>
< tr >

< th > 类型:< /个 >
< td > {4} < / td >
< / tr >

< / table >
computer.name,computer.price,computer.processor,computer.ram,computer .type,computer.image));
lblout.Text = sb.ToString();
}
}

protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)
{
fillpage();
}
< / script >

解决方案

将id属性添加到你的img中这样





服务器端你可以通过它的id访问它

另外,不要在代码中连接表,使用asp:Repeater并将模板化的标题和行放入其占位符,然后在适当的事件中填充数据(RowDataBound或任何你需要的)。您甚至可以在模板中执行此操作,它将填充DataSource数据:

]]>




Google asp:Repeater [ ^ ]

请进行此更改并尝试...

< img id =my-imagerunat =serversrc =〜/ empty-image .jpg/> 



..

放一个倾斜(〜)..

谢谢..


my code in explorer debugger(F12) :

<tr>

         <th rowspan='5' width='150px'><img runat='Server' src='../pic/cs1.jpg'></th>
         <th width='50px'>Name:</td>
         <td>laptop</td>
</tr>






this is my real code :

private void fillpage()
    {

        ArrayList comuterlist = connectionclass.getcomputertype(!IsPostBack ? "%" : DropDownList1.SelectedValue);
        StringBuilder sb = new StringBuilder();
        foreach (Cpmuter computer in comuterlist)
        {
            sb.Append(
                string.Format(
              @"<table class='computertable'>
<tr>

         <th rowspan='5' width='150px'><img runat='Server' src='{5}'></th>
         <th width='50px'>Name:</td>
         <td>{0}</td>
</tr>

<tr>

         <th>Price:</th>
         <td>{1}</td>
</tr>
<tr>

         <th>Processor:</th>
         <td>{2}</td>
</tr>
<tr>

         <th>Ram:</th>
         <td>{3}</td>
</tr>
<tr>

         <th>Type:</th>
         <td>{4}</td>
</tr>

 </table>",
         computer.name, computer.price, computer.processor, computer.ram, computer.type, computer.image));
            lblout.Text = sb.ToString();
        }
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        fillpage();
    }
</script>

解决方案

Add the id attribute to your img like this


Server side you can access it through its id
Also, don't concatenate table(s) in the code, use asp:Repeater and put your templated header and row into its placeholders and then fill the data in suitable events (RowDataBound or whatever you need). You can even do this in the template and it will be filled with DataSource data:
]]>


Google asp:Repeater[^]


Please make This Changes And Try...

<img id="my-image" runat="server" src="~/empty-image.jpg" />


..
Put A Tilt(~)..
Thanks..


这篇关于我如何在我的网站中显示图像..表中的商店是否有类型Varchar(255)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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