asp.net gridview绑定ratiobutton 和ajax
protected void RbIsManual_CheckedChanged(object sender, EventArgs e) { RadioButton rb = sender as RadioButton; if (rb != null) { GridViewRow row = rb.Parent.Parent as GridViewRow; Button confirm = (Button)row.FindControl("save"); confirm.Enabled = true; } }
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="AerocraftsGridView" runat="server" AutoGenerateColumns="False" AllowPaging="True" BackColor="White" BorderColor="Silver" BorderStyle="Ridge" BorderWidth="1px" CellPadding="3" CellSpacing="1" GridLines="None" onpageindexchanging="AerocraftsGridView_PageIndexChanging" onrowdatabound="AerocraftsGridView_RowDataBound" PageSize="20" > <AlternatingRowStyle BackColor="White" /> <Columns> <asp:TemplateField HeaderText="型号名称" ItemStyle-Width="130px"> <ItemTemplate> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="型号"> <ItemTemplate> <asp:RadioButton ID="rbzy" runat="server" Text="在研" GroupName="在研标示" AutoPostBack="True" oncheckedchanged="RbInResearch_CheckedChanged" /> <asp:RadioButton ID="rbywc" runat="server" AutoPostBack="True" Text="已完成" GroupName="在研标示" oncheckedchanged="RbIsComplete_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="形式"> <ItemTemplate> <asp:RadioButton ID="rbsd" runat="server" AutoPostBack="True" GroupName="Type" Text="手动" oncheckedchanged="RbIsManual_CheckedChanged" /> <asp:RadioButton ID="rbzd" runat="server" AutoPostBack="True" GroupName="Type" Text="自动" oncheckedchanged="RbIsAutomatic_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="操作"> <ItemTemplate> <asp:Button ID="save" runat="server" CssClass="btn_2k3" ForeColor="White" Height="23px" Width="77px" Text="确 定" onclick="Save_Click" Enabled="False" /> </ItemTemplate> </asp:TemplateField> </Columns> <EditRowStyle BackColor="#2461BF" /> <EmptyDataTemplate> 对不起,数据为空! </EmptyDataTemplate> <AlternatingRowStyle BackColor="#E6F7FE" /> <HeaderStyle BackColor="#B5CAE7" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#B5CAE7" ForeColor="#305A68" /> <FooterStyle BackColor="#B5CAE7" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#B5CAE7" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView> <br /> <asp:LinkButton ID="btnFirst" CommandArgument="first" OnClick="PagerButtonClick" runat="server">首 页</asp:LinkButton> <asp:LinkButton ID="btnPrev" CommandArgument="prev" OnClick="PagerButtonClick" runat="server">上一页</asp:LinkButton> <asp:LinkButton ID="btnNext" CommandArgument="next" OnClick="PagerButtonClick" runat="server">下一页</asp:LinkButton> <asp:LinkButton ID="btnLast" CommandArgument="last" OnClick="PagerButtonClick" runat="server">尾 页</asp:LinkButton> <asp:Label ID="LblCurrentIndex" runat="server"></asp:Label> <asp:Label ID="LblPageCount" runat="server"></asp:Label> <asp:Label ID="LblRecordCount" runat="server"></asp:Label><br /><br /> <asp:Label ID="explain" runat="server" Text="(不可操作的是已纳入基线的型号)"></asp:Label> </ContentTemplate> </asp:UpdatePanel>