Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Programmatically binding datagrid

Reply
Thread Tools

Programmatically binding datagrid

 
 
Niclas Lindblom
Guest
Posts: n/a
 
      04-08-2004
Hi,

I have a datagrid that contains a checkbox template column. I have followed
the sample in Q306227, but I have a problem evaluating the content of the
datagrid columns to decide a value for the checkboxes check property.

According to the sample I should use this statement in the BindCheckbox
event to evaluate a column:

Public Sub BindCheckBox(ByVal sender As Object, ByVal e As EventArgs)
'Create a new instance of a CheckBox.
Dim oCheckBox As CheckBox = CType(sender, CheckBox)
Dim container As DataGridItem = CType(oCheckBox.NamingContainer,
DataGridItem)
'Evaluate the data from the Grid item and set the Checked property
' appropriatly
If container.DataItem("contract").GetType.ToString = "System.DBNull"
Then
oCheckBox.Checked = False
Else
oCheckBox.Checked = CBool(container.DataItem("contract"))
End If

End Sub


The problem here is that my project is configured to use "Option Strict" and
does therefore not allow the statement

If container.DataItem("contract").GetType.ToString = "System.DBNull" Then

I tried to use Container.cells(2).text instead, but this only returns a
empty string in all rows.

Any suggestions on how to to do this ?

Regards

Niclas


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      04-08-2004
Hi, Niclas

Why not try
If IsDBNull(container.DataItem("contract")) The
oCheckBox.Checked = Fals
Els
oCheckBox.Checked = CBool(container.DataItem("contract")
End I

Bin Song, MC

----- Niclas Lindblom wrote: ----

Hi

I have a datagrid that contains a checkbox template column. I have followed
the sample in Q306227, but I have a problem evaluating the content of the
datagrid columns to decide a value for the checkboxes check property

According to the sample I should use this statement in the BindCheckbox
event to evaluate a column

Public Sub BindCheckBox(ByVal sender As Object, ByVal e As EventArgs
'Create a new instance of a CheckBox
Dim oCheckBox As CheckBox = CType(sender, CheckBox
Dim container As DataGridItem = CType(oCheckBox.NamingContainer,
DataGridItem
'Evaluate the data from the Grid item and set the Checked propert
' appropriatl
If container.DataItem("contract").GetType.ToString = "System.DBNull"
The
oCheckBox.Checked = Fals
Els
oCheckBox.Checked = CBool(container.DataItem("contract")
End I

End Su


The problem here is that my project is configured to use "Option Strict" and
does therefore not allow the statemen

If container.DataItem("contract").GetType.ToString = "System.DBNull" The

I tried to use Container.cells(2).text instead, but this only returns a
empty string in all rows

Any suggestions on how to to do this

Regard

Niclas



 
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
Binding a GridView Programmatically =?Utf-8?B?TWlrZSBDb2xsaW5z?= ASP .Net 1 11-06-2006 09:19 AM
GridView binding - how to stop initial binding Amit ASP .Net 6 10-24-2006 08:06 AM
pywin32 COM sort in Excel (late binding fails, early binding works) (+py2exe) kogrover@gmail.com Python 2 10-20-2006 04:08 PM
How to programmatically access ObjectDataSource values (instead of binding to data controls) ASP .Net 2 06-28-2005 07:59 PM
Data Binding - using inline code vs. functions vs. straight binding Jordan ASP .Net 2 02-10-2004 08:32 PM



Advertisments