Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Help me understand what is wrong (Data not showing)

Reply
Thread Tools

Help me understand what is wrong (Data not showing)

 
 
Lorenzo
Guest
Posts: n/a
 
      12-28-2005
Hello there I have somenthing pretty strange to me that I am trying to
understand but I seem to fail.

I have the following simple code that works fine in one scenario and give me
an hard time in another one. I have understood where the problem is but
there is a main concept that I am not getting and I need to understand.
What I am doing is programmatically create a table and filling it with 2
records and then bind it to a GridView control. It works fine if a place
the code in one single page, it does not if I place the code in the code
behind...

Code that works within the tag <SCRIPT> is here:
<%@ Import Namespace = "System.Data" %>

<script language="VB" runat="server">

Sub Page_Load(sender as Object, e as EventArgs)

If Not Page.IsPostBack then

'Create the DataTable

Dim dt as New DataTable()


'Create the columns

Dim dcName as New DataColumn("Name", GetType(String))

Dim dcAge as New DataColumn("Age", GetType(Integer))


'Add the columns to the DataTable's Columns collection

dt.Columns.Add(dcName)

dt.Columns.Add(dcAge)


'Add some rows

Dim dr as DataRow

dr = dt.NewRow()

dr("Name") = "Scott"

dr("Age") = 25

dt.Rows.Add(dr)


dr = dt.NewRow()

dr("Name") = "Jisun"

dr("Age") = 24

dt.Rows.Add(dr)


dr = dt.NewRow()

dr("Name") = "Sam"

dr("Age") = 5

dt.Rows.Add(dr)



'Bind the DataTable to the DataGrid

dgPeople.DataSource = dt

dgPeople.DataBind()

End If

End Sub

</script>

The same code place in a code behind page differs only in the Page_Load
event that has the following code:

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

If Not Page.IsPostBack Then

'Create the DataTable

Dim dt As New DataTable()

....the rest of the code is exactly the same

Here I don't get an error but my GridView doesn' show any data, why is that
? Could someone refer me to to what the ByVal does? My little knowledges
tell me that is a difference that is so that variables are referred by their
address position in memory instead of a copy of the actual value. This is
as far as I go, but you can tell I have no very much clear what all that
means. I really thank someone who can give me a hint to make my code above
work (that should be simple) and refer me to a resource where I can learn
more about byRef and ByVal.

I hope I was clear.
Lore



 
Reply With Quote
 
 
 
 
addup
Guest
Posts: n/a
 
      12-28-2005
Your page_Load is missing the handles

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

i.e. it is never being executed

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't understand what's wrong with this function... hirsh.dan@gmail.com C++ 5 08-02-2008 05:20 PM
Printing a char* which is not a string: I do not understand this Hendrik Maryns C Programming 8 01-25-2008 04:55 PM
Threading Library, I don't understand what is wrong here. smorrey@gmail.com C++ 3 10-20-2006 05:43 PM
Getting linking error: not found in vtable (Trying to understand whats wrong the way I did my classes?) g35rider@gmail.com C++ 1 08-17-2006 05:10 PM
Read all of this to understand how it works. then check around on otherRead all of this to understand how it works. then check around on other thelisa martin Computer Support 2 08-18-2005 06:40 AM



Advertisments