如何在下一页asp.net中发送gridview图像 [英] how to send gridview image in next page asp.net

查看:69
本文介绍了如何在下一页asp.net中发送gridview图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,这是查看页面吗?

string constr = ConfigurationManager.ConnectionStrings [CONSTR]。ConnectionString;

private int id = 0;



protected void Page_Load(object sender,EventArgs e)

{

id = Convert.ToInt32(Request.QueryString [ id]。ToString());

if(!IsPostBack)

{

BindControlvalues();

}



}



private void BindControlvalues()

{

SqlConnection con = new SqlConnection(constr);

con.Open();

SqlCommand cmd = new SqlCommand(select * from tbl_addnewproduct where id =+ id,con);

SqlDataAdapter da = new SqlDataAdapter(cmd);

cmd.ExecuteNonQuery();

con。关闭();

Dat aSet ds = new DataSet();

da.Fill(ds);

Image1.ImageUrl = ds.Tables [0] .Rows [0] [1]。 ToString();

Label1.Text = ds.Tables [0] .Rows [0] [2] .ToString();

Label2.Text = ds.Tables [0] .Rows [0] [3] .ToString();



}



* ****这是gridview页面********

hi sir this is view page?
string constr = ConfigurationManager.ConnectionStrings["CONSTR"].ConnectionString;
private int id = 0;

protected void Page_Load(object sender, EventArgs e)
{
id = Convert.ToInt32(Request.QueryString["id"].ToString());
if (!IsPostBack)
{
BindControlvalues();
}

}

private void BindControlvalues()
{
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("select * from tbl_addnewproduct where id=" + id, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
con.Close();
DataSet ds = new DataSet();
da.Fill(ds);
Image1.ImageUrl = ds.Tables[0].Rows[0][1].ToString();
Label1.Text = ds.Tables[0].Rows[0][2].ToString();
Label2.Text = ds.Tables[0].Rows[0][3].ToString();

}

*****this is gridview page********

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

        DataSourceID="SqlDataSource1" Width="237px">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"

                ReadOnly="True" SortExpression="id" />
             <asp:TemplateField HeaderText="Image">
                        <ItemTemplate>
                         <img alt ="" src ='images/<%#Eval("imagename") %>' height="50px" width="50px" />
                          </ItemTemplate>
                        </asp:TemplateField>

           <asp:TemplateField>
<ItemTemplate>
<a href ='<%#"viewdeatil.aspx?id="+DataBinder.Eval(Container.DataItem,"id") %>'> <%#Eval("Name") %>  </a>
</ItemTemplate>
</asp:TemplateField>
            <asp:BoundField DataField="product" HeaderText="product"

                SortExpression="product" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

        ConnectionString="<%$ ConnectionStrings:BussinessConnectionString %>"

        SelectCommand="SELECT [id], [imagename], [Name], [product] FROM [tbl_addnewproduct]">
    </asp:SqlDataSource>
</td></tr></table></div>
</div>





i想要在点击查看按钮后显示下一页中的gridview图像

但是上面的代码工作但图像没有显示;

谢谢sir



i want to show the gridview image in next page after click view button
but above code working but image is not show;
thanks sir

推荐答案

ConnectionStrings:BussinessConnectionString %>

SelectCommand = SELECT [id],[imagename],[Name],[product] FROM [tbl_addnewproduct] >
< / asp:SqlDataSource >
< / td > < / tr > < / table > < / div >
< / div >
ConnectionStrings:BussinessConnectionString %>" SelectCommand="SELECT [id], [imagename], [Name], [product] FROM [tbl_addnewproduct]"> </asp:SqlDataSource> </td></tr></table></div> </div>





i想在点击查看按钮后在下一页显示gridview图像

但是代码工作以上但图片没有显示;

谢谢先生



i want to show the gridview image in next page after click view button
but above code working but image is not show;
thanks sir


这篇关于如何在下一页asp.net中发送gridview图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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