2011-02-04 7 views
1

내가 원하는 것은 사용자가 삭제 버튼을 클릭 할 때 전체 행을 강조 표시하고 삭제하기 전에 확인을 요청하고 아래에 내 코드 및 iw ant가 표시됩니다. 두 단계를 실행하십시오 : 1) 전체 행을 높이십시오. 2) 확인을 요청하십시오.강조 표시 GridView 삭제 버튼을 클릭 할 때만 행

protected void gvOrg_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    Button btnDelete = (Button)e.Row.FindControl("btnDelete"); 
    if (btnDelete != null) 
    { 
      //btnDelete.Attributes.Add("onclick", e.Row.BackColor = System.Drawing.Color.Red); 
      btnDelete.Attributes.Add("onclick", String.Format(textForMessage, "Id: " + DataBinder.Eval(e.Row.DataItem, "Id"), "Name: " + DataBinder.Eval(e.Row.DataItem, "Name"))); 
    } 
} 

답변

4
protected void gvOrg_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    Button btnDelete = (Button)e.Row.FindControl("btnDelete"); 
    if (btnDelete != null) 
    { 
    btnDelete.Attributes.Add("onclick", 
     String.Format(@"return DeleteRow('{0}',{1});", 
     e.Row.ClientID,e.Row.RowIndex)); 
    } 
} 

//javascript 
function DeleteRow(rowId, rowIdx) 
{ 
    HighlightRow(rowId, "#FF0000"); 
    var result = confirm('Are you sure you want to delete this record?'); 
    if(!result) 
    HighlightRow(rowId, rowIdx % 2 ? "#DEEEE9" : "#FFFFFF"); 
    return result; 
} 

function HighlightRow(rowId, color) 
{ 
    var row = document.getElementById(rowId);  
    row.style.background = color; 
} 
+0

하나 개의 작은 것은 내가'행을 번갈아 것을 foud '그래서 난이 같은 교류 행을 복원 할 수있는 방법? –

+0

행을 번갈아 처리하도록 코드를 수정했습니다. – Phaedrus

+0

+1 Phaedrus 감사합니다. –

관련 문제