2014-07-10 2 views
0

바닥 글이 표시로 설정되어 있으며 생성되는 것을 볼 수 있습니다. 그러나 합계 (테이블 합계)가 넘겨지면 GridView2.FooterRow가 null임을 나타내는 오류가 발생합니다. totTable은 합계를 운반하는 DataTable을 나타냅니다.GridView 바닥 글 행이 null입니다.

영문 :

ShowHeader="true" ShowFooter="true" FooterStyle-CssClass="FooterStyle" 

CS :

DataRow dr = totTable.Rows[0]; 
foreach (DataControlField col in GridView2.Columns) 
       { 
        foreach (DataColumn dc in totTable.Columns) 
        { 
         int i = GridView2.Columns.IndexOf(col); 
         GridView2.FooterRow.Cells[i].Text = dr[i].ToString(); 

        } 
       } 

근본 원인이 뒤에 무엇입니까?

+1

'박사 [I]'는 무엇입니까? – Hyarantar

+0

@Hyarantar oh yeah ... dataTable Row .. 게시물을 편집하겠습니다. – bonCodigo

+0

좋아, 나는 그것을 해결할 수 있었다. 주로 바닥 글에 액세스하려고 할 때 GridView2가 * 초기화되지 않기 때문입니다. 그래서 여기에 있습니다 ... – bonCodigo

답변

0

사용은 구속력있는 gridview 후 코드를 다음

public void CountGrandTotal() 
    { 
     int sum = 0; 
     for (int i = 0; i <grdproduct.Rows.Count ; i++) 
     { 
      Label lblprice = (Label)grdproduct.Rows[i].FindControl("Label5"); 

      sum += int.Parse(lblprice.Text); 
     } 
     Label lblgtotal = (Label)grdproduct.FooterRow.FindControl("Label7"); 
     lblgtotal.Text = sum.ToString(); 
+0

내 마지막 코멘트를 본 적이 있는지 확실하지 않습니다. 나는 그것을 해결했다. 그래도 고마워. – bonCodigo

+0

또한, 오늘부터,'FindControl'은 제 코드에서 단지 귀찮은 것입니다 ... – bonCodigo

관련 문제