2012-03-21 5 views
0

나는 colone에서 mysql을 정렬한다고 생각하고 싶습니다. colone title과 imagebutton이 다음에 있습니다. imagebutton을 클릭하면 databind myrepeater를, 나는 imageurl을 변경하고 싶습니다. 내가 image.ImageUrl = "~ \ 데이터 \ 로고를 \두면 그 후하여 ImageButton의, 내가 databinded되고 있음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; 
    } 
} 

예기치 않은, 내 중계기 그러나 이미지 URL과 같은 일을하고있어, 수정되지 않을 s_asc .png "; LoadSortedData없이 혼자 리피터를 클릭하면 이미지 URL이 변경됩니다.

+0

_if, else_를 입력하기 전에 사용한 ImageUrl은 무엇입니까? 어쩌면 ImageUrl 경로가 상대 경로 문자열과 일치하지 않을 수 있습니다. – Coder

+0

"~ \\ Data \\ logos \\ s_asc.png"이 있는데 그 문제가 그다지 나오지 않으면 "image.ImageUrl ="~ \ Data \ logos \ s_asc.png를 남겨 두었습니까? "; LoadSortedData없이 혼자 중계기에 데이터 바인딩하는 이미지 URL을 클릭하면 변경됩니다." –

+0

'LoadSortedData()의 코드가 try/catch 블록에 래핑 되었습니까? 귀하의 코드는 리피터 컨트롤을 재 바인딩합니다.'LoadSortedData()'다음에'ImageButton image = (ImageButton) UserRepeater.Controls [0] .Controls [0] .FindControl (criteres); – Coder

답변

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; 
     } 
    } 

thx 코더이 코드는 저에게 적합합니다.

관련 문제