【问题标题】:Getting textbox and checkbox values which is in edit item template of gridview in a string获取字符串中gridview的编辑项模板中的文本框和复选框值
【发布时间】:2013-07-16 22:22:26
【问题描述】:

这是我的 vb.net 代码,用于更新预订汽车的人的姓名,以及他是否想要交流或非交流汽车由复选框处理。当我单击gridview中的编辑按钮时。我得到一个文本框来编辑人员和一个复选框来选择汽车交流类型。单击更新后,文本框代码不会检索已编辑的文本框值,而是采用绑定的文本框值。就像假设如果我从 Mathew 编辑到 John,那么它需要 Mathew,它不会使用 John 的值。与复选框类似,即使我选中了复选框。复选框的选中属性显示为假。请帮我解决一下这个。

Protected Sub gvBooking_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvBooking.RowUpdating
            Dim name As String = DirectCast(gvBooking.Rows(e.RowIndex).FindControl("txtperson1"), TextBox).Text

            Dim id As Integer = Integer.Parse(gvBooking.DataKeys(e.RowIndex).Value.ToString)


            Dim carac As String = "False"


            Dim chk As CheckBox = CType(gvBooking.Rows(e.RowIndex).FindControl("CheckBox1"), CheckBox)
            If (chk.Checked = True) Then
                carac = "True"
            End If


            Dim sql As String = ""
            sql = "update dbo.tbl_Book set person_name='" + name + "',ac_type='" + carac + "' where booking_id = " + id.ToString
            gc.ExecuteCommand(sql)
            gvBooking.EditIndex = -1
            gc.BindGridView(gvBooking, "select * from tbl_Book")
        End Sub

【问题讨论】:

    标签: asp.net .net vb.net visual-studio-2008 gridview


    【解决方案1】:

    检查您是否在页面回发属性之外的页面加载中绑定了网格视图

    【讨论】:

    • 谢谢哥们。非常感谢。你的回答有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 2014-07-07
    • 2017-01-16
    • 2015-11-23
    • 1970-01-01
    相关资源
    最近更新 更多