问题使用两个Girdview控件时。 [英] Problem While using the two Girdview controls.

查看:85
本文介绍了问题使用两个Girdview控件时。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一网页上使用了两个girdview控件。当我从gridview1中删除记录时,girdview2会自动编辑和删除。为什么会发生这种情况?

这是从gridview中删除行的代码。

Am using two girdview controls on same webpage . when I delete the records from gridview1 automatically girdview2 enables the edit and delete . why this is happening?
This is code for deleting the row from gridview .

Protected Sub DeleteFuncObjDetails(ByVal sender As Object, ByVal e As EventArgs)
       lblobjerrmsg.Visible = False
       lblperwtfactmsg.Visible = False
       lblwtfactmsg.Visible = False
       If GridViewMBOFuncObjDetalis.Rows.Count <> 0 Then
           Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
           Dim con As New SqlConnection(strConnString)
           Dim cmd As New SqlCommand()
           cmd.CommandType = CommandType.Text
           cmd.CommandText = "delete from MBO_Details where " & _
           "id=@idnum;" & _
           "select id, MBO_FUNC_OBJ, MBO_MEASURED_VAR, MBO_DEADLINE,MBO_WEIGHT_FACT from MBO_Details where MBO_EMP_CODE='" & (EMP_NO) & "'"
           cmd.Parameters.Add("@idnum", SqlDbType.VarChar).Value = lnkRemove.CommandArgument
           GridViewMBOFuncObjDetalis.DataSource = GetDataMBOFuncObjDetails(cmd)
           GridViewMBOFuncObjDetalis.DataBind()
       End If
       Dim Conn As New SqlConnection(strConnString)
       Dim sum As Double = 0.0
       Dim Comm1 As New SqlCommand("select MBO_WEIGHT_FACT from MBO_Details where MBO_EMP_CODE='" & EMP_NO & "'", Conn)
       Conn.Open()
       Dim DR1 As SqlDataReader = Comm1.ExecuteReader()
       While DR1.Read()
           Dim member As String = DR1("MBO_WEIGHT_FACT").ToString()
           sum = sum + Convert.ToDouble(member)
       End While
       txtfuncwttotal.Text = sum
       BindDataMBOFuncObjDetails()
   End Sub

推荐答案

Quote:

你为什么要打电话 BindDataMBOFuncObjDetails ()最后因为你已经完成了上面的绑定了吗?



还有一件事,通过附加断点来调试代码第二个网格的事件并查看它们是否在网格1 中删除时被点击。

Why are you calling BindDataMBOFuncObjDetails() at last as you have already done the binding above that?

One more thing, debug your code by attaching break points on the 2nd Grid's Events and see if they are getting hit while you delete in Grid 1.

OP说: - 谢谢先生。

OP says :- Thank you sir.

这篇关于问题使用两个Girdview控件时。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆