在数据列表中点击图片后发送ID [英] send id when image clicked in datalist

查看:89
本文介绍了在数据列表中点击图片后发送ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在使用数据列表在imagebutton中查看数据库中的图像,并希望在单击图像时转到具有该图像ID的另一页,以从数据库中获取该图像的详细信息

数据列表的此代码

hi all
i am using datalist to view image from database in imagebutton and want when clicked to image go to another page with id of this image to get the details of this image from database

this code of datalist

asp:DataList ID="DataList1" runat="server"  RepeatColumns="3"  OnItemCommand="DataList1_ItemCommand" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Both" Width="719px"  >
        <ItemTemplate>
            <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl='<%#Eval("image")%>' CommandName="selectimage" Width=100 Height=100 /><br />





我正在CS中使用此代码





i am using this code in cs

protected void DataList1_ItemCommand(object source,
        System.Web.UI.WebControls.DataListCommandEventArgs e)

    {

        if (e.CommandName == "selectimage")
        {

            int Id = int.Parse(e.CommandArgument.ToString());
            
            Response.Redirect("~/clothes3.aspx?Id=" + e.CommandArgument.ToString());

        }
    }



但单击图像时出现异常,但我没有原因



but get an exception when clicked on image but i do not the reason

推荐答案

该错误表示它的意思.如果按照它说的做以避免这种错误,那么您的代码可能会起作用.您还可以在Google上搜索确切的错误消息,以阅读其他人在此实例中所做的事情.
The error means what it says. If you do what it says in order to avoid this error, then your code will probably work. You can also google the exact error message to read what other people have done in this instance.


这篇关于在数据列表中点击图片后发送ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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