0
我想要做同样的事情我们认为我们的mysql在colone上排序,我有表colone标题和imagebutton下一个,当我点击imagebutton我databind myrepeater,我想改变imageurl之后的的ImageButton的,我做这样的在更改imagebutton图像之前等待数据绑定
protected void UserRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "country":
break;
default:
string criteres = e.CommandName;
ImageButton image = (ImageButton)UserRepeater.Controls[0].Controls[0].FindControl(criteres);
if (image.ImageUrl == "~\\Data\\logos\\s_desc.png")
{
LoadSortedData(criteres, "DESC", 1);
image.ImageUrl = "~\\Data\\logos\\s_asc.png";
}
else
{
LoadSortedData(criteres, "ASC", 1);
image.ImageUrl = "~\\Data\\logos\\s_desc.png";
}
break;
}
}
意外,我的中继器被databinded但图像的URL将不被修改,如果我离开image.ImageUrl =“〜\ DATA \商标\ s_asc巴纽“;单独没有LoadSortedData哪个数据绑定中继器的图像URL更改点击,任何想法呢?
你在进入_if,else_之前有什么ImageUrl?可能ImageUrl路径与这些相对路径字符串不匹配。 – Coder 2012-03-21 16:27:12
我有“〜\\ Data \\ logos \\ s_asc.png”并且问题不是来自这个问题,我在问题“如果我离开image.ImageUrl =”〜\ Data \ logos \ s_asc.png “;单独没有LoadSortedData的数据绑定中继器的图像URL更改点击” – 2012-03-21 16:35:30
“LoadSortedData()'内的代码包装在try/catch块吗?你的代码是重新绑定中继器控件,试着在'LoadSortedData()'后面写'ImageButton image =(ImageButton)UserRepeater.Controls [0] .Controls [0] .FindControl(criteres);''。 – Coder 2012-03-21 17:43:20