2010-07-26 65 views
0

Fincontrol在檢查GridView中的複選框不工作

  <asp:BoundField DataField="mail" SortExpression="mail" HeaderText="Com Rec"> 
       <HeaderStyle Font-Size="X-Small" ForeColor="White" HorizontalAlign="Left" /> 
       <ItemStyle Font-Size="X-Small" HorizontalAlign="Left" /> 
      </asp:BoundField> 

     <asp:TemplateField HeaderText="Status Change"> 
     <ItemTemplate> 
      &nbsp;<asp:CheckBox ID="chkstatus" Width=5px runat="server" /> 
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
     </ItemTemplate> 
     </asp:TemplateField> 
      <asp:TemplateField> 
       <ItemTemplate> 
        <asp:HiddenField ID="hdID" runat="server" Value='<%# eval("DATE_CREATED") %>' /> 
        <asp:HiddenField ID="qiaid" runat="server" Value='<%# eval("ID") %>' /> 
       </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
    </asp:GridView> 

代碼背後

昏暗xitem作爲GridViewRow

Dim ID As HiddenField 

    For Each xitem In datagrid1.Rows 

     Dim rowCount As Integer 
     rowCount = datagrid1.Rows.Count 

     Dim tempvalue1 As CheckBox 

     'For i = 0 To (rowCount - 1) 
     xitem.Cells(13).Text.ToString() 
     tempvalue1 = DirectCast(xitem.Cells(13).FindControl("chkstatus"), CheckBox) 




     If tempvalue1.Checked = True Then 
          QIA_ID = xitem.FindControl("qiaid") 
      Dim strUpdate As String 

      strUpdate   
    Try 
       Dim cmd As DbCommand 
       cmd = QIA.GetSqlStringCommand(strUpdate) 
       QIA.ExecuteNonQuery(cmd) 
       Label1.Text = "Succesfylly moved to Archive" 
       Label1.Visible = True 

     End If 
    Next 

tempcheckbox總是顯示false..please建議我

+0

你在RowCommand事件執行的代碼? – 2011-06-07 04:36:35

+0

嘗試Dim tempvalue1作爲CheckBox = DirectCast(xitem.FindControl(「chkstatus」),CheckBox) – 2011-06-07 04:36:50

回答

0

頁面不回傳

0

要在GridView中查找複選框(C#)

複選框CHK =(複選框).GridView1.Rows [e.RowIndex] .FindControl( 「chkbox」);

在上面的語法

Gridview1是的GridView的名稱, chkbox是複選框的名字..

相關問題