我想做同样的想法我们对colone的mysql排序,我有表colone标题和下一个图像按钮,当我点击图像按钮我databind myrepeater并且我想在此之后更改图像按钮的图像,我这样做
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数据绑定转发器图像网址点击更改,任何想法?
答案 0 :(得分:0)
protected void UserRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int bookid;
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 = (ImageButton)UserRepeater.Controls[0].Controls[0].FindControl(criteres);
image.ImageUrl = "~\\Data\\logos\\s_asc.png";
}
else
{
LoadSortedData(criteres, "ASC", 1);
image = (ImageButton)UserRepeater.Controls[0].Controls[0].FindControl(criteres);
image.ImageUrl = "~\\Data\\logos\\s_desc.png";
}
break;
}
}
编码器这个代码适用于我。