GridView中得到选中的某行的ID值

//前台
 <asp:TemplateField HeaderText="ID">
                <ItemTemplate>
                    <asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

//后台
 for (int i = 0; i < this.GridView1.Rows.Count; i++)
                {
                    bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("CB")).Checked;
                    if (isChecked)
                    {
                        ID = ((Label)GridView1.Rows[i].FindControl("lblID")).Text;
                    }
                }

posted @ 2011-08-08 21:44  风一样的大叔  阅读(226)  评论(0)    收藏  举报