【发布时间】:2012-03-21 15:45:57
【问题描述】:
我想做同样的事情,认为我们在colone上进行mysql排序,接下来我有表colone标题和一个imagebutton,当我点击imagebutton时我数据绑定myrepeater,然后我想更改imagebutton的imageurl,我就是这样的
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;
}
}
出乎意料,如果我离开 image.ImageUrl = "~\Data\logos\s_asc.png";单独没有 LoadSortedData 哪个数据绑定转发器点击时图像 url 更改,对此有任何想法吗?
【问题讨论】:
-
在输入 if, else 之前你有什么 ImageUrl ?也许 ImageUrl 路径与那些相对路径字符串不匹配。
-
我有 "~\\Data\\logos\\s_asc.png" 问题不是来自那个,我在问题中说 "如果我离开 image.ImageUrl = "~\ Data\logos\s_asc.png"; 单独没有 LoadSortedData 数据绑定转发器点击时图像 url 更改"
-
LoadSortedData()中的代码是否包含在 try/catch 块中?您的代码正在重新绑定中继器控件,请尝试在LoadSortedData()之后编写ImageButton image = (ImageButton)UserRepeater.Controls[0].Controls[0].FindControl(criteres);。
标签: asp.net repeater wait data-binding