GridView中的RadioButton和CheckBox

    <asp:TextBox ID="txt" runat="server" />

<asp:GridView id="GridView1" runat="server"  AutoGenerateColumns="False" Width="100%"  CellPadding="4" GridLines="None" ShowHeader="False" ><Columns>
<asp:BoundField DataField="UserId">
    <ItemStyle Width="100px" />
</asp:BoundField>
    <asp:TemplateField HeaderText="Select One">
        <ItemTemplate>
          <input name="MyRadioButton" type="radio"
                    value='<%# Eval("UserId") %>' onclick='document.getElementById("<%=txt.ClientID %>").value = this.value;' />
        </ItemTemplate>
      </asp:TemplateField> 

<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
    <ItemStyle HorizontalAlign="Center" />
    <HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>

<asp:BoundField DataField="UserName" HeaderText="用户帐号">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
</asp:BoundField>

<asp:BoundField DataField="CreateDate" HeaderText="创建日期">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
</asp:BoundField>

</Columns>
        <RowStyle BackColor="#E3EAEB" />
        <AlternatingRowStyle BackColor="White" />
</asp:GridView>
//<asp:TextBox ID="txt" runat="server" />获取的值就是radiobutton的值.

posted on 2008-02-27 13:58  秋天  阅读(303)  评论(0编辑  收藏  举报

导航