【问题标题】:Validating a TextBox if a Checkbox is checked (inside GridView)如果选中了复选框,则验证文本框(在 GridView 内)
【发布时间】:2012-02-21 10:54:33
【问题描述】:

我在 ASP.NET 页面中有以下标记:

<asp:GridView ID="gv" runat="server" DataSourceID="ods" OnRowDataBound="gv_RowDataBound">
    <columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:CheckBox ID="cb" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField>
            <ItemTemplate>
                <asp:TextBox ID="tbx" runat="server"/>
            </ItemTemplate>
        </asp:TemplateField>
    </columns>
</asp:GridView>

如何仅在选中 CheckBox 时验证 TextBox

我搜索了类似的情况,但找不到任何东西。
谢谢。

【问题讨论】:

    标签: asp.net validation gridview


    【解决方案1】:

    U 可以使用 RowCommand,在该命令下你可以使用 int index = AuthorsGridView.EditIndex; 获取控件状态 GridViewRow 行 = AuthorsGridView.Rows[index];然后验证文本框

    参考这个http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-19
      • 2016-07-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-28
      • 2011-09-28
      相关资源
      最近更新 更多