日期:2014-05-19  浏览次数:20524 次

获取GridViw中CheckBox的值
<asp:GridView   ID= "GridView1 "   runat= "server "   AutoGenerateColumns= "False "   DataSourceID= "SqlDataSource1 ">
                <FooterStyle   BackColor= "#990000 "   Font-Bold= "true "   ForeColor= "white "   />
                <Columns>
                        <asp:BoundField   DataField= "VoteID "   HeaderText= "VoteID "   ReadOnly= "true "   SortExpression= "VoteID "   />
                        <asp:BoundField   DataField= "item "   HeaderText= "项目名 "   SortExpression= "item "   />
                      <asp:TemplateField>
                              <ItemTemplate>
                                <asp:CheckBox   runat= "server "   id= "cbxID "   />
                              </ItemTemplate>
                      </asp:TemplateField>
                </Columns>
                <RowStyle   BackColor= "#FFFBD6 "   ForeColor= "#333333 "   HorizontalAlign= "center "   />
                </asp:GridView>
                <asp:SqlDataSource   ID= "SqlDataSource1 "   runat= "server "   ConnectionString= " <%$appSettings:SqlConnnectionString   %> "   SelectCommand= "Select   VoteID,Item   From   Votes "> </asp:SqlDataSource>
                <br   />
                <asp:Button   ID= "btnVote_Click "   runat= "server "   OnClick= "btnVote_Click_Click "   Text= "我要投票 "   />
-------------------------这是前后GridView的代码。。
---------------------------------
protected   void   btnVote_Click_Click(object   sender,   EventArgs   e)
        {
                try
                {
                    //     web   Web   =   new   web();
                        foreach   (GridViewRow   item   in   GridView1.Rows)
                        {
                                CheckBox   check   =   (CheckBox)item.FindControl( "cbxID &q