2010-05-29 5 views
0

내 asp.net 3.5 응용 프로그램 [C#]에서 gridview 있습니다. 어떤은 다음과 같습니다asp.net의 코드 배후에서 gridview 업데이트

<asp:GridView CssClass="grid_table" ID="GridView1" AllowPaging="true" PageSize="10" 
     AutoGenerateEditButton="true" ShowHeader="true" 
     AutoGenerateDeleteButton="true" DataKeyNames="studentId" runat="server" 
     OnRowEditing="GridView1_RowEditing" 
     OnRowCancelingEdit="GridView1_RowCancelingEdit" 
     OnRowDeleting="GridView1_RowDeleting" 
     OnRowUpdating="GridView1_RowUpdating" 
     onpageindexchanging="GridView1_PageIndexChanging" onrowupdated="GridView1_RowUpdated" 
     > 

    <EmptyDataTemplate> 
     <asp:Label ID="lblNoRecord" runat="server" Text="No Record Found" ForeColor="Red"> </asp:Label> 
    </EmptyDataTemplate> 

</asp:GridView> 

을 지금의 RowUpdating 이벤트에서, 나는 아래의 코드를 작성하고이에

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) 
{ 
    int mytext = Convert.ToInt16(GridView1.Rows[e.RowIndex].Cells[1].Text); 
    string cConatiner = GridView1.Rows[e.RowIndex].Cells[4].Text; 
} 

을 myText를이 1 열 즉하지만 때, 나에게 정확한 값을주고있다 셀 값을 1,2,3,4,5,6으로 변경하면 비어 있습니다.

잘못하고 있습니까?

도와주세요.

미리 감사드립니다.

+0

도와주세요. 솔루션을 찾을 수 없습니다. – Zerotoinfinity

+0

당신의 cConatiner는 항상 비어 있습니다. 그것은 당신의 문제입니까? DB/(다른 소스)에서 가져온 데이터를 확인 했습니까? – chapluck

+0

데이터 집합에서 내 gridview 바인딩 오전 및 gridview 9 열 및 16 행을 보여줍니다, 셀 값을 가져올 수 없습니다. – Zerotoinfinity

답변

1

셀의 값을 mytext 값으로 설정하는 위치가 표시되지 않습니다. 나는 아래의 코드에서 셀 [4]의 값을 설정하려고한다고 가정하기 위하여려고하고있다 : [4] 셀 당신이 설정하는 셀을 원하지 않을 경우

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) 
{ 
    int mytext = Convert.ToInt16(GridView1.Rows[e.RowIndex].Cells[1].Text); 
    string cConatiner = GridView1.Rows[e.RowIndex].Cells[4].Text; 

    GridView1.Rows[e.RowIndex].Cells[4].Text = mytext; 
} 

, 적절하게 변경합니다.