Click here to Skip to main content
15,898,792 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .
VB
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
Posted
Updated 26-Feb-14 17:56pm
v2
Comments
Charan_Kumar 26-Feb-14 23:48pm    
show the code.
Ni!E$H_WAGH 27-Feb-14 0:02am    
I havve added the code by improving question. please have look through this.
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.
Ni!E$H_WAGH 27-Feb-14 0:47am    
Thank you sir.
I have added one answer. Please accept and up vote. :)

Thanks,
Tadit

1 solution

Quote:
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 says :- Thank you sir.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900