Last post Nov 11, 2008 04:09 AM by pjxyz
Nov 07, 2008 03:37 AM|pjxyz|LINK
I have a dataset which has 4 field columns and variable number of rows depending upon the records existing in database....When i query i want the dataset to be loaded as text in labels....i have the count(number of rows) present in the dataset...How can
Nov 07, 2008 09:13 AM|DkUltra|LINK
Why not use a gridview control ? why is an array of labels needed ?
but a person could do this in a generic list(of label)
Hope this helps
Nov 07, 2008 10:11 AM|pjxyz|LINK
Actually i am making a portal and want to display the announcements(or events)..these are usually shown in form of labels in the web sites...gridview is not preffered..so can u guide me????
Nov 07, 2008 10:38 AM|DkUltra|LINK
ok how about something like this
for each row in dataset
dim lbl as new label
dim sb as sytem.text.stringbuilder
your container.add(lbl) ' a div a form whatever container your using
Hope this helps
Nov 08, 2008 01:49 PM|pjxyz|LINK
I tried this but it shows null ref exception
Dim ds3 As New DataSet
Dim da As New OleDbDataAdapter(con.cmd)
count = ds3.Tables(0).Rows.Count
Dim dr As DataRow
For Each dr In ds3.Tables(0).Rows
Dim lbl As New Label
Dim sb As System.Text.StringBuilder
'exception on next line
lbl.Text = sb.ToString()
Controls.Add(lbl) ' a div a form whatever container your using
Nov 08, 2008 05:44 PM|DkUltra|LINK
What is giving the null reference ?
may be datarow ?
For Each dr as datarow In ds3.Tables(0).Rows
or a collumn in the row ?
Nov 09, 2008 01:09 AM|pjxyz|LINK
dr is not giving null refernce exception...the exception is at sb.Append(dr("date").ToString)
System.NullReferenceException: Object reference not set to an instance of an object.
Nov 09, 2008 01:12 AM|pjxyz|LINK
is there something that sb has to be initialized to????It also says sb is used before it is assgined any value.....i guess instead append property some other has to be used?
Nov 09, 2008 02:19 PM|DkUltra|LINK
dim sb as new system.t .....stringbuilder
Nov 11, 2008 04:06 AM|pjxyz|LINK
ya its working thanks a lot
Nov 11, 2008 04:09 AM|pjxyz|LINK