2011-08-02 6 views
0

Gridview를 autogenerate columns = true로 설정했습니다. 일부 열의 동적 텍스트 상자를 만들었습니다. footer button gridview rowcomand 이벤트를 클릭하면이 명령이 실행되지 않습니다. 바인드해야합니다. 다시있는 gridview는하지만 난 텍스트 상자의 변화는 .. 다음 사라가 내 값을 바인딩 할 때 나의 코드 rowdatabound 이벤트Gridview 동적 컨트롤 문제

protected void grdMaterialPercentage_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
     if (grdMaterialPercentage.AutoGenerateColumns == true) 
     { 
      if (e.Row.RowType == DataControlRowType.Header) 
      { 
       e.Row.Cells[0].Visible = false; 
      } 

      if (e.Row.RowType == DataControlRowType.DataRow) 
      { 
       e.Row.Cells[0].Visible = false; 
       if (DataBinder.Eval(e.Row.DataItem, "AgentName").ToString() != string.Empty) 
       { 
        int i = 0; 
        foreach (TableCell c in e.Row.Cells) 
        { 
         if (i >= 3) 
         { 
          TextBox tb = new TextBox(); 
          tb.Text = c.Text; 
          tb.ID = "txtbox" + i.ToString(); 
          tb.Style.Add("Width", "25px"); 
          tb.Style.Add("Height", "15px"); 
          c.Controls.Clear(); 
          c.Controls.Add(tb); 

         } 
         i++; 
        } 
       } 
       else 
       { 
        e.Row.Visible = false; 
       } 
      } 

      if (e.Row.RowType == DataControlRowType.Footer) 
      { 
       e.Row.Cells[0].Visible = false; 
       int j = 0; 
       foreach (TableCell c in e.Row.Cells) 
       { 

        if (j >= 3) 
        { 
         DataRow dr = dt.Rows[dt.Rows.Count - 1]; 
         LinkButton btn = new LinkButton(); 

         btn.ID = "FooterButton" + j.ToString(); 

         btn.CommandName = j.ToString(); 
         btn.Text = "Save" + dr[j - 1].ToString(); 
         btn.CssClass = "button"; 
         btn.Style.Add("align", "center"); 
         btn.CommandArgument = dr[j - 1].ToString(); 
         btn.OnClientClick = "return ValidateTotalPercentage('" + j + "')"; 
         c.Controls.Clear(); 
         c.Controls.Add(btn); 

        } j++; 
       } 
      } 
     } 
    } 

답변

0

이다 나는 당신이 후드 아래에 무슨 일이 일어나고 있는지보고 등 방화범 같은 도구를 사용하는 것이 좋습니다 그리드의 링크를 클릭하면 Javascript가 표시됩니다. 이것이 제가 당신의 신발에서 할 일입니다.