User-2015346030 posted
this is what i am doing right now. i am making another datatable and m comparing designation there with my query string which contains value for current logged in user. but the problem with this method is :
1st : it adds a blank row in my gridview
2nd: when i am trying to add another datatable which has information about that designation it is not binding with the right record.
Protected Sub Gridparent_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles Gridparent.SelectedIndexChanged
Dim row As GridViewRow = Gridparent.SelectedRow
Dim desig As String = row.Cells(8).Text
Dim sValue As String = DirectCast(row.FindControl("lbldesi"), Label).Text
Dim trans As String = row.Cells(10).Text
Dim tid As String = DirectCast(row.FindControl("lbtrans"), Label).Text
HiddenField1.Value = tid
Dim Str1 As String
Str1 = "select distinct a.*,b.empno from ranu.desgmaster a, tt.employees b where (b.active='T') and a.desgid = b.desgid and desiglevel < (select DesigLevel from ranu.desgmaster where desgid = " & Val(sValue) & ") and b.deptcode in (select DEPTID from jatinder.DeptWiseAuth where status='A' and empid='" & Request.QueryString("wempno") & "') and a.MinLeavApp <= 1 and a.MaxLeavApp >= 1 order by Designation"
Dim cmd As New Oracle.cls_OracleCommand
Dim dtg As New DataTable
dtg = cmd.ExecuteAdapter(Str1)
Request.QueryString("wempno") & "' "
Dim finaldt As New DataTable
With finaldt.Columns
.Add("designation")
.Add("Authstatus")
.Add("authBy")
.Add("Remarks")
.Add("Authdate")
End With
Dim str3 As String
str3 = "select AUTHSTATUS,REMARKS, authby,authdate from testleave"
cmd.ExecuteNonQuery(str3)
Dim ddp1 As New OracleDataAdapter(str3, con)
Dim tt1 As New DataTable
ddp1.Fill(tt1)
Dim typ As String
typ = "select empdesignation from tt.employees where empno='" & Request.QueryString("wempno") & "' "
cmd.ExecuteNonQuery(typ)
Dim ndp As New OracleDataAdapter(typ, con)
Dim st As New DataTable
ndp.Fill(st)
Dim row_234 As DataRow = finaldt.NewRow
row_234("designation") = st.Rows(0)(0).ToString()
finaldt.Rows.Add(row_234)
If dtg.Rows.Count > 0 Then
For Each dr As DataRow In dtg.Rows
Dim row_23 As DataRow = finaldt.NewRow
If st.Rows(0)(0).ToString() <> dr("designation") Then
If dtg.Rows(0)("empno") = tt1.Rows(0)("authby") Then
row_23("Authstatus") = tt1.Rows(0)("authstatus").ToString()
row_23("authby") = tt1.Rows(0)("authby").ToString()
row_23("remarks") = tt1.Rows(0)("remarks").ToString()
row_23("Authdate") = tt1.Rows(0)("authdate").ToString()
End If
row_23("designation") = dr("designation").ToString()
End If
finaldt.Rows.Add(row_23)
Next
End If
Dim str2 As String
str2 = "select Designation from ranu.desgmaster where LeaveAdmin = 'Y' order by Designation"
cmd.ExecuteNonQuery(str2)
Dim ddp As New OracleDataAdapter(str2, con)
Dim tt As New DataTable
ddp.Fill(tt)
If tt.Rows.Count > 0 Then
For Each dr As DataRow In tt.Rows
Dim row_23 As DataRow = finaldt.NewRow
If st.Rows(0)(0).ToString() <> dr("designation") Then
row_23("designation") = dr("designation").ToString()
End If
finaldt.Rows.Add(row_23)
Next
End If
Gridchild.DataSource = finaldt
Gridchild.DataBind()
End Sub