473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

drivign me crazy for last 2 days - itemdatabound


hi
i have a link in the datagrid which are actually the names of the
files..what i am doign is when i click to that link i display the
description of that file below it. i have implemented something simialr
before.

the problem now is that when i click the link my datagrid jsut vanishes.

ran thru the debugger...after i click the link it comes to the
dgFiles_ItemCommand then this condition "ElseIf (e.CommandName =
"ShowContent") Then" is satisfied to is goes to the bindGrid; from bind
grid it goes to ==>
dgFiles_ItemDataBound
here is just repeates the dgFiles_ItemDataBound event only 2ice. once
for header and once for footer.

why is this happening..why does the datagird only have header and
footer?

Private Sub dgFiles_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgFiles.ItemCommand

If e.CommandName = "File" Then

/////
ElseIf e.CommandName = "Delete" Then
////
ElseIf (e.CommandName = "ShowContent") Then 'this is what is causing
problem

dgFiles.EditItemIndex = e.Item.ItemIndex
bindGrid()

End If
Private Sub dgFiles_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgFiles.ItemDataBound

If e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.Alternating Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.EditItem Then
Dim lbl As System.Web.UI.WebControls.Label
lbl = e.Item.FindControl("lblSize")
FilePath = e.Item.Cells(1).Text
filename = e.Item.Cells(2).Text
Dim fi As FileInfo = New FileInfo(FilePath & filename)
Dim fileBytes As Integer = (fi.Length / 1024)
lbl.Text = fileBytes.ToString
End If
If e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.Alternating Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item Then
Dim link As System.Web.UI.WebControls.LinkButton =
CType(e.Item.FindControl("select"),
System.Web.UI.WebControls.LinkButton)
link.Text = e.Item.Cells(2).Text
End If
Dim itemType As System.Web.UI.WebControls.ListItemType =
e.Item.ItemType
If (e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.EditItem) Then
Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim title As System.Web.UI.WebControls.Label =
CType(e.Item.FindControl("Title"), System.Web.UI.WebControls.Label)
Dim content As System.Web.UI.WebControls.Label =
CType(e.Item.FindControl("content"), System.Web.UI.WebControls.Label)
title.Text = row("FILENAME").ToString()
Dim contentStr As String = ByteArrayToString(row("DESCRIPTION"))
content.Text = contentStr
End If
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
4 1184
I am not sure what bindGrid() does when it is called in the 'ShowContent'
part. Probably, showing bindGrid() code will help.

"samir dsf" <im************@gmail.com> wrote in message
news:Oe**************@TK2MSFTNGP09.phx.gbl...

hi
i have a link in the datagrid which are actually the names of the
files..what i am doign is when i click to that link i display the
description of that file below it. i have implemented something simialr
before.

the problem now is that when i click the link my datagrid jsut vanishes.

ran thru the debugger...after i click the link it comes to the
dgFiles_ItemCommand then this condition "ElseIf (e.CommandName =
"ShowContent") Then" is satisfied to is goes to the bindGrid; from bind
grid it goes to ==>
dgFiles_ItemDataBound
here is just repeates the dgFiles_ItemDataBound event only 2ice. once
for header and once for footer.

why is this happening..why does the datagird only have header and
footer?

Private Sub dgFiles_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgFiles.ItemCommand

If e.CommandName = "File" Then

/////
ElseIf e.CommandName = "Delete" Then
////
ElseIf (e.CommandName = "ShowContent") Then 'this is what is causing
problem

dgFiles.EditItemIndex = e.Item.ItemIndex
bindGrid()

End If
Private Sub dgFiles_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgFiles.ItemDataBound

If e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.Alternating Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.EditItem Then
Dim lbl As System.Web.UI.WebControls.Label
lbl = e.Item.FindControl("lblSize")
FilePath = e.Item.Cells(1).Text
filename = e.Item.Cells(2).Text
Dim fi As FileInfo = New FileInfo(FilePath & filename)
Dim fileBytes As Integer = (fi.Length / 1024)
lbl.Text = fileBytes.ToString
End If
If e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.Alternating Item Or
e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item Then
Dim link As System.Web.UI.WebControls.LinkButton =
CType(e.Item.FindControl("select"),
System.Web.UI.WebControls.LinkButton)
link.Text = e.Item.Cells(2).Text
End If
Dim itemType As System.Web.UI.WebControls.ListItemType =
e.Item.ItemType
If (e.Item.ItemType =
System.Web.UI.WebControls.ListItemType.EditItem) Then
Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim title As System.Web.UI.WebControls.Label =
CType(e.Item.FindControl("Title"), System.Web.UI.WebControls.Label)
Dim content As System.Web.UI.WebControls.Label =
CType(e.Item.FindControl("content"), System.Web.UI.WebControls.Label)
title.Text = row("FILENAME").ToString()
Dim contentStr As String = ByteArrayToString(row("DESCRIPTION"))
content.Text = contentStr
End If
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #2
here is my bindgrid

Public Sub bindGrid()
Try
'CheckValidate
Page.Validate()
If Not Page.IsValid Then
Return
End If

'get details from the db
GoToDBOpenConn()

strSQL = "select FILEID, FILENAME,
APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION FROM DOWNLOADFILES WHERE
@lower(ORGANISATION)=@lower('" & Orgn & "') and FILEREPORT='FILE' "

'CHECK WHAT APPLICATION TYPES AND SERVICES ARE CHOSEN BY
THIS USER
strSQL2 = "select
DESKTOP,NETWORK,DATACENTRE,PREMIUM,SERVER,HELPDESK FROM SERVICETYPES
where @lower(USERNAME) = @lower('" & Session("GlobalUserName") & "')"
objCommand = New OleDbCommand(strSQL2, objConnection)
objReaderServiceType = objCommand.ExecuteReader()
Dim flagCONCAT As Boolean = False
Dim endSQL As String
While (objReaderServiceType.Read())

If objReaderServiceType("DESKTOP") = 1 Or
objReaderServiceType("DATACENTRE") = 1 Or _
objReaderServiceType("PREMIUM") = 1 Or
objReaderServiceType("SERVER") = 1 Or _
objReaderServiceType("HELPDESK") = 1 Or
objReaderServiceType("NETWORK") = 1 Then
Dim startSQL As String = " AND ("
endSQL = " ) "
flagCONCAT = True
strSQL = strSQL & startSQL
End If
Dim flagOR As Boolean = False
Dim midSQL As String = " OR "
If objReaderServiceType("DESKTOP") = 1 Then
flagOR = True
strSQL = strSQL & " APPSERVICETYPE='DESKTOP'"
End If
If objReaderServiceType("DATACENTRE") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='DATACENTRE'"
End If
If objReaderServiceType("PREMIUM") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='PREMIUM'"
End If
If objReaderServiceType("SERVER") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='SERVER'"
End If
If objReaderServiceType("HELPDESK") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='HELPDESK'"
End If
If objReaderServiceType("NETWORK") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='NETWORK'"
End If
End While
If flagCONCAT = True Then
strSQL = strSQL & endSQL
End If
objReaderServiceType.Close()
GoToDBCloseConn()
If flagCONCAT = True Then
GoToDBOpenConn()
objCommand = New OleDbCommand(strSQL, objConnection)
myDa.SelectCommand = objCommand
Dim dt As New DataTable
myDa.Fill(dt)
Me.dgFiles.DataSource = dt
Me.dgFiles.DataBind()

End If
Catch ex As Exception
lblError.Text = "bindGrid(): " & ex.Message.ToString
Finally
GoToDBCloseConn()
End Try
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3

only problem now is that when i click the link ... i dont see the
datagrid at all..

so it means the datasource is not being provided. but i ran thru the
debugger

after i click the link it comes to the
dgFiles_ItemCommand then this condition "ElseIf (e.CommandName =
"ShowContent") Then" is satisfied to is goes to the bindGrid; from bind
grid it goes to ==>
dgFiles_ItemDataBound
here is just repeates the dgFiles_ItemDataBound event only 2ice. once
for header and once for footer.

why is this happening..why si the datagird empty?


*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #4
Hi,

bindGrid() looks ok to me. Probably, you might want to execute the SQL query
constructed by this procedure separately and check that you are getting one
or more rows.

"samir dsf" <im************@gmail.com> wrote in message
news:uq**************@TK2MSFTNGP12.phx.gbl...
here is my bindgrid

Public Sub bindGrid()
Try
'CheckValidate
Page.Validate()
If Not Page.IsValid Then
Return
End If

'get details from the db
GoToDBOpenConn()

strSQL = "select FILEID, FILENAME,
APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION FROM DOWNLOADFILES WHERE
@lower(ORGANISATION)=@lower('" & Orgn & "') and FILEREPORT='FILE' "

'CHECK WHAT APPLICATION TYPES AND SERVICES ARE CHOSEN BY
THIS USER
strSQL2 = "select
DESKTOP,NETWORK,DATACENTRE,PREMIUM,SERVER,HELPDESK FROM SERVICETYPES
where @lower(USERNAME) = @lower('" & Session("GlobalUserName") & "')"
objCommand = New OleDbCommand(strSQL2, objConnection)
objReaderServiceType = objCommand.ExecuteReader()
Dim flagCONCAT As Boolean = False
Dim endSQL As String
While (objReaderServiceType.Read())

If objReaderServiceType("DESKTOP") = 1 Or
objReaderServiceType("DATACENTRE") = 1 Or _
objReaderServiceType("PREMIUM") = 1 Or
objReaderServiceType("SERVER") = 1 Or _
objReaderServiceType("HELPDESK") = 1 Or
objReaderServiceType("NETWORK") = 1 Then
Dim startSQL As String = " AND ("
endSQL = " ) "
flagCONCAT = True
strSQL = strSQL & startSQL
End If
Dim flagOR As Boolean = False
Dim midSQL As String = " OR "
If objReaderServiceType("DESKTOP") = 1 Then
flagOR = True
strSQL = strSQL & " APPSERVICETYPE='DESKTOP'"
End If
If objReaderServiceType("DATACENTRE") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='DATACENTRE'"
End If
If objReaderServiceType("PREMIUM") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='PREMIUM'"
End If
If objReaderServiceType("SERVER") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='SERVER'"
End If
If objReaderServiceType("HELPDESK") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='HELPDESK'"
End If
If objReaderServiceType("NETWORK") = 1 Then
If flagOR = True Then
strSQL = strSQL & midSQL
Else
flagOR = True
End If
strSQL = strSQL & " APPSERVICETYPE='NETWORK'"
End If
End While
If flagCONCAT = True Then
strSQL = strSQL & endSQL
End If
objReaderServiceType.Close()
GoToDBCloseConn()
If flagCONCAT = True Then
GoToDBOpenConn()
objCommand = New OleDbCommand(strSQL, objConnection)
myDa.SelectCommand = objCommand
Dim dt As New DataTable
myDa.Fill(dt)
Me.dgFiles.DataSource = dt
Me.dgFiles.DataBind()

End If
Catch ex As Exception
lblError.Text = "bindGrid(): " & ex.Message.ToString
Finally
GoToDBCloseConn()
End Try
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
12
by: EMW | last post by:
I'm really getting frustrated.. I'm trying to create an interactive datagrid to be used in a sort of planning tool. In my company we have 25 engineers and they run a 24/7 call duty once a...
3
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
1
by: Joe Blanchard via .NET 247 | last post by:
Hello, Can someone please help me. I thought this would be simple but so far nothing I try works..... I've got a simple update page. On this page I have a datalist bound by data from a SQL...
5
by: Nathan Sokalski | last post by:
I have a control that I want displayed in all items except the last one. I figured the best way to do this was to determine whether the current item was the last from within the ItemDataBound event...
7
by: bkasmai | last post by:
This is driving me crazy. I need to hide rows that a particular cell is zero. On debuggng I fiound out that ItemDataBound fires for header only and not for Item and AlternatingItem private void...
4
by: GaryDean | last post by:
I'm up against something else I used to easily do in a DataGrid that is different in a GridView.... I used to access cells in non-visible columns in the ItemDataBound event. The data was there -...
2
by: Nathan Sokalski | last post by:
I have a DataList control that I use the ItemDataBound event for. One of the properties of the DataList that I use in this event is Me.datMain.Items.Count (datMain is the id of my DataList) in...
1
by: Nathan Sokalski | last post by:
I am trying to set the CommandArgument property of a Button control from a template in a DataList of mine using code in the ItemDataBound event. However, it does not want to set the property (it is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.