[已解决]如何重定向到图像按钮(位于数据列表控件中)单击时的差异页面? [英] [Solved] How to redirect to a diff page on image button(residing inside datalist control) click?

查看:47
本文介绍了[已解决]如何重定向到图像按钮(位于数据列表控件中)单击时的差异页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在数据列表控件中有一个图像按钮.此按钮显示来自数据库并填充数据列表的图像.
现在,我想根据用户单击的图像的image_id将用户重定向到"secondpage.aspx"页面.
所以基本上就像Response.Redirect(Seconpage.aspx?Img_Id=100).
所以我尝试了,

Hi,
I have one image button inside datalist control.This button shows the images which are from the database and populating the datalist.
Now I want to redirect the user to a "secondpage.aspx" page based on the image_id of the image he clicks.
So basically its like Response.Redirect(Seconpage.aspx?Img_Id=100).
So I have tried,

PostBackUrl=''Secondpage.aspx?ProjectId<%#DataBinder.Eval(Container.DataItem,"ProjectId") %>''<%#DataBinder.Eval(Container.DataItem,"ProjectId") %>''


它将我重定向到Secondpage.aspx,但是querystring值不可见.
该怎么办?


来自OP的更新:

问题解决了.请看下面的答案之一.


It is redirecting me to Secondpage.aspx, but the querystring value is not visible.
What to do?


UPDATE from OP:

Issue resolved. Look at one of the answers below.

推荐答案

尝试类似的方法,
Try something like this,
PostBackUrl=''<%#Eval("ProjectId", "Secondpage.aspx?ProjectId={0}")%>''




or

PostBackUrl=''Secondpage.aspx?ProjectId=<%#Eval("ProjectId") %>''


上面的代码未经测试.但是您可以执行类似的操作.


Above code is not tested. But you can do something similar.


我想这意味着您需要修复代码,该代码目前似乎包含%,然后是#,而不是<.
I would guess that means that you need to fix your code, which currently seems to have the %, then # and not the < to precede them.



我找到了答案,这就是我所做的:
PostBackUrl =''<%#GetUrl(DataBinder.Eval(Container.DataItem,"ProjectId"))%>''
在CodeBehind中,我编写了GetUrl函数,如下所示:
Hi,
I have found the answer,This is what I have done:
PostBackUrl=''<%#GetUrl(DataBinder.Eval(Container.DataItem, "ProjectId")) %>''
and in CodeBehind,I have written the GetUrl function as below:
protected string GetUrl(object ProjectId)
{
        return string.Format("~/Default2.aspx?ProjectId={0}", ProjectId);
}


无论如何,谢谢您的帮助!


Thanks for your help anyway!


这篇关于[已解决]如何重定向到图像按钮(位于数据列表控件中)单击时的差异页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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