chandu_2512 0 Newbie Poster

hi,
i am developing paging in asp web application by using VB.net.
i am getting out put for when i am setting the paging for 10 but it is not going for the next page with paging.If i set the paging to8 or less than 10 i am getting the error "index was out of range" in the line 213.


please let me know the actual problem and answer with the code.

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.mail
PublicClass dash
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents anl As System.Web.UI.WebControls.HyperLink
Protected WithEvents up As System.Web.UI.WebControls.HyperLink
Protected WithEvents ah As System.Web.UI.WebControls.HyperLink
Protected WithEvents au As System.Web.UI.WebControls.HyperLink
Protected WithEvents eu As System.Web.UI.WebControls.HyperLink
Protected WithEvents ap As System.Web.UI.WebControls.HyperLink
Protected WithEvents ep As System.Web.UI.WebControls.HyperLink
Protected WithEvents Panel4 As System.Web.UI.WebControls.Panel
Protected WithEvents hm As System.Web.UI.WebControls.HyperLink
Protected WithEvents al As System.Web.UI.WebControls.HyperLink
Protected WithEvents ms As System.Web.UI.WebControls.HyperLink
Protected WithEvents mh As System.Web.UI.WebControls.HyperLink
Protected WithEvents ac As System.Web.UI.WebControls.HyperLink
Protected WithEvents pr As System.Web.UI.WebControls.HyperLink
Protected WithEvents el As System.Web.UI.WebControls.HyperLink
Protected WithEvents eh As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink5 As System.Web.UI.WebControls.HyperLink
Protected WithEvents l1 As System.Web.UI.WebControls.Label
Protected WithEvents dge As System.Web.UI.WebControls.DataGrid
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents mon As System.Web.UI.WebControls.DropDownList
Protected WithEvents yr As System.Web.UI.WebControls.DropDownList
Protected WithEvents alrtimg As System.Web.UI.WebControls.ImageButton
Protected WithEvents alrtpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents totpendlvs As System.Web.UI.WebControls.Label
Protected WithEvents editpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim cnt, lv, s, cnt1 As Integer
Dim concn As String = ConfigurationSettings.AppSettings("ORACLEConnectionString")
Dim odbc As New OleDbConnection(concn)
Dim da As New OleDbDataAdapter("select * from team", Odbc)
Dim ds As New DataSet
Dim qry, eid, ct, outputstring As String
Dim i As Integer
Public mc As New OleDbConnection("Provider='OraOLEDB.Oracle.1';User ID=leaveasmtdb;Data Source=orchqadb;Extended Properties=;Persist Security Info=True;Password=leaveasmtdb")
Public com, cmd As New OleDbCommand
Public da1 As New OleDbDataAdapter
Public ds1 As New DataSet
Dim p, z As Integer
Dim dat As New Date
 
 
 
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' Ajax.Utility.RegisterTypeForAjax(GetType(Dashboard))
If Page.IsPostBack = False Then
If Session.IsNewSession Or Session.SessionID.Equals("") Then
Response.Redirect("Expire.aspx")
End If
Binddata()
eid = Session("sessEmpid")
ct = Session("sessCat")
l1.Text = "Welcome " & Session("sessFirstName") & " (" & ct & ")"
If ct = "Trainee" Or ct = "Team member" Or ct = "" Then
pr.Visible = False
el.Visible = False
eh.Visible = False
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
End If
Else
Binddata()
End If
Dim path As String = Server.MapPath("login.aspx")
qry = "select a.lv_id as lid,a.emp_id as ceid from applies a where ((a.from_dt >= ?)or (a.lv_type='SL'))and lv_id in (select lv_id from stat where (auth_by='" & eid & "' and status='Pending' or status='ToCancel') or (appr_by='" & eid & "' and status='Authorized'))"
cmd = New OleDbCommand(qry, odbc)
cmd.Parameters.Add("from_dt", Date.Today)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
cnt = ds1.Tables(0).Rows.Count
For s = 0 To ds1.Tables(0).Rows.Count - 1
lv = ds1.Tables(0).Rows(s).Item(0)
Session("sslv1") = lv
Next
If cnt > 0 Then
totpendlvs.Text = cnt
alrtimg.Visible = True
alrtpend.Visible = True
Else
totpendlvs.Visible = False
alrtimg.Visible = False
alrtpend.Visible = False
End If
Dim pemp, psta As String
qry = "select emp_id,status from stat where status='Pending'"
cmd = New OleDbCommand(qry, odbc)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
For z = 0 To ds1.Tables(0).Rows.Count - 1
pemp = ds1.Tables(0).Rows(z).Item(0)
psta = ds1.Tables(0).Rows(z).Item(1)
If pemp = eid And psta = "Pending" Then
editpend.Visible = True
editpend.Text = "Edit Your Pending Leaves"
Exit For
Else
editpend.Visible = False
End If
Next
' Response.Write(path)
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
odbc.Close()
odbc.Dispose()
End Sub
Public Sub Binddata()
Dim aa, cc As Integer
Dim bb, sts As String
eid = Session("sessEmpid")
ct = Session("sessCat")
Dim frmdt, emil As String
frmdt = (yr.SelectedValue) + "-" + (mon.SelectedValue).ToString
da = New OleDbDataAdapter("select distinct(e.emp_id)as emp,e.fname as name,e.email from employee e ,stat s, applies a where e.emp_id=s.emp_id and a.emp_id=s.emp_id and to_char(from_dt,'yyyy-mon') ='" & frmdt & "' ", mc)
da.Fill(ds, "employee")
Dim i, cnt As Integer
If ds.Tables(0).Rows.Count >= 0 Then
Label1.Visible = False
dge.Visible = True
cnt = dat.DaysInMonth(Int32.Parse(yr.SelectedValue), mon.SelectedIndex + 1)
editpend.Visible = False
For i = 1 To cnt
Dim bc As New BoundColumn
If i < 10 Then
bc.HeaderText = "0" + i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
Else
bc.HeaderText = i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
End If
Next
dge.DataSource = ds.Tables(0)
dge.DataBind()
Dim emp As String
Dim qry As String
qry = "select to_char(a.from_dt,'dd'), to_char(a.to_dt,'dd'), a.lv_id,s.status ,s.emp_id from applies a ,stat s where a.lv_id=s.lv_id and to_char(from_dt,'yyyy-mon') like '" & frmdt & "%'"
com = New OleDbCommand(qry, mc)
da = New OleDbDataAdapter(com)
ds1 = New DataSet
da.Fill(ds1)
Dim j, k, p As Integer
For j = 0 To ds.Tables(0).Rows.Count - 1
emil = ds.Tables(0).Rows(j).Item(2)
'Session("ssmail") = ds.Tables(0).Rows(j).Item(2)
For k = 0 To ds1.Tables(0).Rows.Count - 1
emp = ds1.Tables(0).Rows(k).Item(4)
sts = ds1.Tables(0).Rows(k).Item(3)
If ds.Tables(0).Rows(j).Item(0) = emp Then
For p = ds1.Tables(0).Rows(k).Item(0) To ds1.Tables(0).Rows(k).Item(1)
aa = ds1.Tables(0).Rows(k).Item(2)
sts = ds1.Tables(0).Rows(k).Item(3)
Session("sslv") = ds1.Tables(0).Rows(k).Item(2)
bb = ds1.Tables(0).Rows(k).Item(4)
emil = ds.Tables(0).Rows(j).Item(2)
If ds1.Tables(0).Rows(k).Item(3) = "Pending" Then
dge.Items(j).Cells(p).Text = "P"
dge.Items(j).Cells(p).BackColor = Color.Orange
'If ct = "Trainee" Or ct = "Team member" Then
'Dim s As String
' s = "window.location.href ='http://localhost/finolams/myStats.aspx'"
'''If eid = emp Then
''' 'alrtpend.Visible = False
''' 'alrtimg.Visible = False
''' editpend.Visible = True
''' editpend.Text = "Edit Your Pending Leaves"
'''Else
''' editpend.Visible = False
''' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'''End If
'If ct = "Team leader" Or ct = "Project Manager" Or ct = "Admin" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Approved" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Green
'If bb = eid Then
' 'alrtpend.Visible = False
' 'alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "smenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Authorized" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Blue
If bb = eid Then
'alrtpend.Visible = False
'alrtimg.Visible = False
'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "pmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Rejected" Then
dge.Items(j).Cells(p).Text = "R"
dge.Items(j).Cells(p).BackColor = Color.Gray
'If bb = eid Then
' alrtpend.Visible = False
' alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "rmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
End If
Next
End If
Next
Next
Else
Label1.Visible = True
Label1.Text = "No Records Found"
dge.Visible = False
End If
End Sub
Sub changePage(ByVal sender As System.Object, ByVal e As DataGridPageChangedEventArgs)
'dge.CurrentPageIndex = e.NewPageIndex
'dge.DataSource = ds.Tables
'dge.DataBind()
End Sub
Private Sub dge_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dge.SelectedIndexChanged
 
End Sub
Private Sub dge_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dge.PageIndexChanged
dge.CurrentPageIndex = e.NewPageIndex
dge.DataSource = ds1.Tables(0)
dge.DataBind()
' Binddata()
End Sub
Private Sub dge_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles dge.Load
 
End Sub
EndClass
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.mail
PublicClass dash
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents anl As System.Web.UI.WebControls.HyperLink
Protected WithEvents up As System.Web.UI.WebControls.HyperLink
Protected WithEvents ah As System.Web.UI.WebControls.HyperLink
Protected WithEvents au As System.Web.UI.WebControls.HyperLink
Protected WithEvents eu As System.Web.UI.WebControls.HyperLink
Protected WithEvents ap As System.Web.UI.WebControls.HyperLink
Protected WithEvents ep As System.Web.UI.WebControls.HyperLink
Protected WithEvents Panel4 As System.Web.UI.WebControls.Panel
Protected WithEvents hm As System.Web.UI.WebControls.HyperLink
Protected WithEvents al As System.Web.UI.WebControls.HyperLink
Protected WithEvents ms As System.Web.UI.WebControls.HyperLink
Protected WithEvents mh As System.Web.UI.WebControls.HyperLink
Protected WithEvents ac As System.Web.UI.WebControls.HyperLink
Protected WithEvents pr As System.Web.UI.WebControls.HyperLink
Protected WithEvents el As System.Web.UI.WebControls.HyperLink
Protected WithEvents eh As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink5 As System.Web.UI.WebControls.HyperLink
Protected WithEvents l1 As System.Web.UI.WebControls.Label
Protected WithEvents dge As System.Web.UI.WebControls.DataGrid
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents mon As System.Web.UI.WebControls.DropDownList
Protected WithEvents yr As System.Web.UI.WebControls.DropDownList
Protected WithEvents alrtimg As System.Web.UI.WebControls.ImageButton
Protected WithEvents alrtpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents totpendlvs As System.Web.UI.WebControls.Label
Protected WithEvents editpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim cnt, lv, s, cnt1 As Integer
Dim concn As String = ConfigurationSettings.AppSettings("ORACLEConnectionString")
Dim odbc As New OleDbConnection(concn)
Dim da As New OleDbDataAdapter("select * from team", Odbc)
Dim ds As New DataSet
Dim qry, eid, ct, outputstring As String
Dim i As Integer
Public mc As New OleDbConnection("Provider='OraOLEDB.Oracle.1';User ID=leaveasmtdb;Data Source=orchqadb;Extended Properties=;Persist Security Info=True;Password=leaveasmtdb")
Public com, cmd As New OleDbCommand
Public da1 As New OleDbDataAdapter
Public ds1 As New DataSet
Dim p, z As Integer
Dim dat As New Date
 
 
 
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' Ajax.Utility.RegisterTypeForAjax(GetType(Dashboard))
If Page.IsPostBack = False Then
If Session.IsNewSession Or Session.SessionID.Equals("") Then
Response.Redirect("Expire.aspx")
End If
Binddata()
eid = Session("sessEmpid")
ct = Session("sessCat")
l1.Text = "Welcome " & Session("sessFirstName") & " (" & ct & ")"
If ct = "Trainee" Or ct = "Team member" Or ct = "" Then
pr.Visible = False
el.Visible = False
eh.Visible = False
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
End If
Else
Binddata()
End If
Dim path As String = Server.MapPath("login.aspx")
qry = "select a.lv_id as lid,a.emp_id as ceid from applies a where ((a.from_dt >= ?)or (a.lv_type='SL'))and lv_id in (select lv_id from stat where (auth_by='" & eid & "' and status='Pending' or status='ToCancel') or (appr_by='" & eid & "' and status='Authorized'))"
cmd = New OleDbCommand(qry, odbc)
cmd.Parameters.Add("from_dt", Date.Today)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
cnt = ds1.Tables(0).Rows.Count
For s = 0 To ds1.Tables(0).Rows.Count - 1
lv = ds1.Tables(0).Rows(s).Item(0)
Session("sslv1") = lv
Next
If cnt > 0 Then
totpendlvs.Text = cnt
alrtimg.Visible = True
alrtpend.Visible = True
Else
totpendlvs.Visible = False
alrtimg.Visible = False
alrtpend.Visible = False
End If
Dim pemp, psta As String
qry = "select emp_id,status from stat where status='Pending'"
cmd = New OleDbCommand(qry, odbc)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
For z = 0 To ds1.Tables(0).Rows.Count - 1
pemp = ds1.Tables(0).Rows(z).Item(0)
psta = ds1.Tables(0).Rows(z).Item(1)
If pemp = eid And psta = "Pending" Then
editpend.Visible = True
editpend.Text = "Edit Your Pending Leaves"
Exit For
Else
editpend.Visible = False
End If
Next
' Response.Write(path)
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
odbc.Close()
odbc.Dispose()
End Sub
Public Sub Binddata()
Dim aa, cc As Integer
Dim bb, sts As String
eid = Session("sessEmpid")
ct = Session("sessCat")
Dim frmdt, emil As String
frmdt = (yr.SelectedValue) + "-" + (mon.SelectedValue).ToString
da = New OleDbDataAdapter("select distinct(e.emp_id)as emp,e.fname as name,e.email from employee e ,stat s, applies a where e.emp_id=s.emp_id and a.emp_id=s.emp_id and to_char(from_dt,'yyyy-mon') ='" & frmdt & "' ", mc)
da.Fill(ds, "employee")
Dim i, cnt As Integer
If ds.Tables(0).Rows.Count >= 0 Then
Label1.Visible = False
dge.Visible = True
cnt = dat.DaysInMonth(Int32.Parse(yr.SelectedValue), mon.SelectedIndex + 1)
editpend.Visible = False
For i = 1 To cnt
Dim bc As New BoundColumn
If i < 10 Then
bc.HeaderText = "0" + i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
Else
bc.HeaderText = i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
End If
Next
dge.DataSource = ds.Tables(0)
dge.DataBind()
Dim emp As String
Dim qry As String
qry = "select to_char(a.from_dt,'dd'), to_char(a.to_dt,'dd'), a.lv_id,s.status ,s.emp_id from applies a ,stat s where a.lv_id=s.lv_id and to_char(from_dt,'yyyy-mon') like '" & frmdt & "%'"
com = New OleDbCommand(qry, mc)
da = New OleDbDataAdapter(com)
ds1 = New DataSet
da.Fill(ds1)
Dim j, k, p As Integer
For j = 0 To ds.Tables(0).Rows.Count - 1
emil = ds.Tables(0).Rows(j).Item(2)
'Session("ssmail") = ds.Tables(0).Rows(j).Item(2)
For k = 0 To ds1.Tables(0).Rows.Count - 1
emp = ds1.Tables(0).Rows(k).Item(4)
sts = ds1.Tables(0).Rows(k).Item(3)
If ds.Tables(0).Rows(j).Item(0) = emp Then
For p = ds1.Tables(0).Rows(k).Item(0) To ds1.Tables(0).Rows(k).Item(1)
aa = ds1.Tables(0).Rows(k).Item(2)
sts = ds1.Tables(0).Rows(k).Item(3)
Session("sslv") = ds1.Tables(0).Rows(k).Item(2)
bb = ds1.Tables(0).Rows(k).Item(4)
emil = ds.Tables(0).Rows(j).Item(2)
If ds1.Tables(0).Rows(k).Item(3) = "Pending" Then
dge.Items(j).Cells(p).Text = "P"
dge.Items(j).Cells(p).BackColor = Color.Orange
'If ct = "Trainee" Or ct = "Team member" Then
'Dim s As String
' s = "window.location.href ='http://localhost/finolams/myStats.aspx'"
'''If eid = emp Then
''' 'alrtpend.Visible = False
''' 'alrtimg.Visible = False
''' editpend.Visible = True
''' editpend.Text = "Edit Your Pending Leaves"
'''Else
''' editpend.Visible = False
''' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'''End If
'If ct = "Team leader" Or ct = "Project Manager" Or ct = "Admin" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Approved" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Green
'If bb = eid Then
' 'alrtpend.Visible = False
' 'alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "smenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Authorized" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Blue
If bb = eid Then
'alrtpend.Visible = False
'alrtimg.Visible = False
'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "pmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Rejected" Then
dge.Items(j).Cells(p).Text = "R"
dge.Items(j).Cells(p).BackColor = Color.Gray
'If bb = eid Then
' alrtpend.Visible = False
' alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "rmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
End If
Next
End If
Next
Next
Else
Label1.Visible = True
Label1.Text = "No Records Found"
dge.Visible = False
End If
End Sub
Sub changePage(ByVal sender As System.Object, ByVal e As DataGridPageChangedEventArgs)
'dge.CurrentPageIndex = e.NewPageIndex
'dge.DataSource = ds.Tables
'dge.DataBind()
End Sub
Private Sub dge_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dge.SelectedIndexChanged
 
End Sub
Private Sub dge_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dge.PageIndexChanged
dge.CurrentPageIndex = e.NewPageIndex
dge.DataSource = ds1.Tables(0)
dge.DataBind()
' Binddata()
End Sub
Private Sub dge_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles dge.Load
 
End Sub
EndClass
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.mail
PublicClass dash
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents anl As System.Web.UI.WebControls.HyperLink
Protected WithEvents up As System.Web.UI.WebControls.HyperLink
Protected WithEvents ah As System.Web.UI.WebControls.HyperLink
Protected WithEvents au As System.Web.UI.WebControls.HyperLink
Protected WithEvents eu As System.Web.UI.WebControls.HyperLink
Protected WithEvents ap As System.Web.UI.WebControls.HyperLink
Protected WithEvents ep As System.Web.UI.WebControls.HyperLink
Protected WithEvents Panel4 As System.Web.UI.WebControls.Panel
Protected WithEvents hm As System.Web.UI.WebControls.HyperLink
Protected WithEvents al As System.Web.UI.WebControls.HyperLink
Protected WithEvents ms As System.Web.UI.WebControls.HyperLink
Protected WithEvents mh As System.Web.UI.WebControls.HyperLink
Protected WithEvents ac As System.Web.UI.WebControls.HyperLink
Protected WithEvents pr As System.Web.UI.WebControls.HyperLink
Protected WithEvents el As System.Web.UI.WebControls.HyperLink
Protected WithEvents eh As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents Hyperlink5 As System.Web.UI.WebControls.HyperLink
Protected WithEvents l1 As System.Web.UI.WebControls.Label
Protected WithEvents dge As System.Web.UI.WebControls.DataGrid
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents mon As System.Web.UI.WebControls.DropDownList
Protected WithEvents yr As System.Web.UI.WebControls.DropDownList
Protected WithEvents alrtimg As System.Web.UI.WebControls.ImageButton
Protected WithEvents alrtpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents totpendlvs As System.Web.UI.WebControls.Label
Protected WithEvents editpend As System.Web.UI.WebControls.HyperLink
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim cnt, lv, s, cnt1 As Integer
Dim concn As String = ConfigurationSettings.AppSettings("ORACLEConnectionString")
Dim odbc As New OleDbConnection(concn)
Dim da As New OleDbDataAdapter("select * from team", Odbc)
Dim ds As New DataSet
Dim qry, eid, ct, outputstring As String
Dim i As Integer
Public mc As New OleDbConnection("Provider='OraOLEDB.Oracle.1';User ID=leaveasmtdb;Data Source=orchqadb;Extended Properties=;Persist Security Info=True;Password=leaveasmtdb")
Public com, cmd As New OleDbCommand
Public da1 As New OleDbDataAdapter
Public ds1 As New DataSet
Dim p, z As Integer
Dim dat As New Date
 
 
 
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' Ajax.Utility.RegisterTypeForAjax(GetType(Dashboard))
If Page.IsPostBack = False Then
If Session.IsNewSession Or Session.SessionID.Equals("") Then
Response.Redirect("Expire.aspx")
End If
Binddata()
eid = Session("sessEmpid")
ct = Session("sessCat")
l1.Text = "Welcome " & Session("sessFirstName") & " (" & ct & ")"
If ct = "Trainee" Or ct = "Team member" Or ct = "" Then
pr.Visible = False
el.Visible = False
eh.Visible = False
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
anl.Visible = False
up.Visible = False
ah.Visible = False
au.Visible = False
eu.Visible = False
ap.Visible = False
End If
Else
Binddata()
End If
Dim path As String = Server.MapPath("login.aspx")
qry = "select a.lv_id as lid,a.emp_id as ceid from applies a where ((a.from_dt >= ?)or (a.lv_type='SL'))and lv_id in (select lv_id from stat where (auth_by='" & eid & "' and status='Pending' or status='ToCancel') or (appr_by='" & eid & "' and status='Authorized'))"
cmd = New OleDbCommand(qry, odbc)
cmd.Parameters.Add("from_dt", Date.Today)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
cnt = ds1.Tables(0).Rows.Count
For s = 0 To ds1.Tables(0).Rows.Count - 1
lv = ds1.Tables(0).Rows(s).Item(0)
Session("sslv1") = lv
Next
If cnt > 0 Then
totpendlvs.Text = cnt
alrtimg.Visible = True
alrtpend.Visible = True
Else
totpendlvs.Visible = False
alrtimg.Visible = False
alrtpend.Visible = False
End If
Dim pemp, psta As String
qry = "select emp_id,status from stat where status='Pending'"
cmd = New OleDbCommand(qry, odbc)
da = New OleDbDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1)
For z = 0 To ds1.Tables(0).Rows.Count - 1
pemp = ds1.Tables(0).Rows(z).Item(0)
psta = ds1.Tables(0).Rows(z).Item(1)
If pemp = eid And psta = "Pending" Then
editpend.Visible = True
editpend.Text = "Edit Your Pending Leaves"
Exit For
Else
editpend.Visible = False
End If
Next
' Response.Write(path)
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
odbc.Close()
odbc.Dispose()
End Sub
Public Sub Binddata()
Dim aa, cc As Integer
Dim bb, sts As String
eid = Session("sessEmpid")
ct = Session("sessCat")
Dim frmdt, emil As String
frmdt = (yr.SelectedValue) + "-" + (mon.SelectedValue).ToString
da = New OleDbDataAdapter("select distinct(e.emp_id)as emp,e.fname as name,e.email from employee e ,stat s, applies a where e.emp_id=s.emp_id and a.emp_id=s.emp_id and to_char(from_dt,'yyyy-mon') ='" & frmdt & "' ", mc)
da.Fill(ds, "employee")
Dim i, cnt As Integer
If ds.Tables(0).Rows.Count >= 0 Then
Label1.Visible = False
dge.Visible = True
cnt = dat.DaysInMonth(Int32.Parse(yr.SelectedValue), mon.SelectedIndex + 1)
editpend.Visible = False
For i = 1 To cnt
Dim bc As New BoundColumn
If i < 10 Then
bc.HeaderText = "0" + i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
Else
bc.HeaderText = i.ToString
dge.Columns.Add(bc)
dge.DataSource = ds.Tables(0)
dge.DataBind()
End If
Next
dge.DataSource = ds.Tables(0)
dge.DataBind()
Dim emp As String
Dim qry As String
qry = "select to_char(a.from_dt,'dd'), to_char(a.to_dt,'dd'), a.lv_id,s.status ,s.emp_id from applies a ,stat s where a.lv_id=s.lv_id and to_char(from_dt,'yyyy-mon') like '" & frmdt & "%'"
com = New OleDbCommand(qry, mc)
da = New OleDbDataAdapter(com)
ds1 = New DataSet
da.Fill(ds1)
Dim j, k, p As Integer
For j = 0 To ds.Tables(0).Rows.Count - 1
emil = ds.Tables(0).Rows(j).Item(2)
'Session("ssmail") = ds.Tables(0).Rows(j).Item(2)
For k = 0 To ds1.Tables(0).Rows.Count - 1
emp = ds1.Tables(0).Rows(k).Item(4)
sts = ds1.Tables(0).Rows(k).Item(3)
If ds.Tables(0).Rows(j).Item(0) = emp Then
For p = ds1.Tables(0).Rows(k).Item(0) To ds1.Tables(0).Rows(k).Item(1)
aa = ds1.Tables(0).Rows(k).Item(2)
sts = ds1.Tables(0).Rows(k).Item(3)
Session("sslv") = ds1.Tables(0).Rows(k).Item(2)
bb = ds1.Tables(0).Rows(k).Item(4)
emil = ds.Tables(0).Rows(j).Item(2)
If ds1.Tables(0).Rows(k).Item(3) = "Pending" Then
     [B]dge.Items(j).Cells(p).Text = "P"[/B]
dge.Items(j).Cells(p).BackColor = Color.Orange
'If ct = "Trainee" Or ct = "Team member" Then
'Dim s As String
' s = "window.location.href ='http://localhost/finolams/myStats.aspx'"
'''If eid = emp Then
''' 'alrtpend.Visible = False
''' 'alrtimg.Visible = False
''' editpend.Visible = True
''' editpend.Text = "Edit Your Pending Leaves"
'''Else
''' editpend.Visible = False
''' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'''End If
'If ct = "Team leader" Or ct = "Project Manager" Or ct = "Admin" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Approved" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Green
'If bb = eid Then
' 'alrtpend.Visible = False
' 'alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "smenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Authorized" Then
dge.Items(j).Cells(p).Text = "A"
dge.Items(j).Cells(p).BackColor = Color.Blue
If bb = eid Then
'alrtpend.Visible = False
'alrtimg.Visible = False
'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
ElseIf ct = "Team leader" Or ct = "Project Manager" Then
'alrtpend.Visible = True
'alrtimg.Visible = True
'editpend.Visible = False
'alrtpend.Text = "Approve or Deny Pending Members>>"
End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "pmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
ElseIf ds1.Tables(0).Rows(k).Item(3) = "Rejected" Then
dge.Items(j).Cells(p).Text = "R"
dge.Items(j).Cells(p).BackColor = Color.Gray
'If bb = eid Then
' alrtpend.Visible = False
' alrtimg.Visible = False
' 'dge.Items(j).Cells(p).Attributes.Add("onmouseover", "tmenu()")
'ElseIf ct = "Team leader" Or ct = "Project Manager" Then
' alrtpend.Visible = True
' alrtimg.Visible = True
' editpend.Visible = False
' alrtpend.Text = "Approve or Deny Pending Members"
'End If
'If ct = "Trainee" Or ct = "Team member" Then
'Else
' dge.Items(j).Cells(p).Attributes.Add("onmouseover", "rmenu();showWin('" & aa & "', '" & bb & "', '" & emil & "')")
'End If
End If
Next
End If
Next
Next
Else
Label1.Visible = True
Label1.Text = "No Records Found"
dge.Visible = False
End If
End Sub
Sub changePage(ByVal sender As System.Object, ByVal e As DataGridPageChangedEventArgs)
'dge.CurrentPageIndex = e.NewPageIndex
'dge.DataSource = ds.Tables
'dge.DataBind()
End Sub
Private Sub dge_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dge.SelectedIndexChanged
 
End Sub
Private Sub dge_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dge.PageIndexChanged
dge.CurrentPageIndex = e.NewPageIndex
dge.DataSource = ds1.Tables(0)
dge.DataBind()
' Binddata()
End Sub
Private Sub dge_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles dge.Load
 
End Sub
EndClass

the bolded area where i am getting error.please let me know the solution.

Thank u.
chandrashekar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.