Problem with ItemDAtaBound event of datalist

B

Bill Yeager

I have a datalist that displays the following when a web
page is rendered:

Community_Property: 2 | Corporation: 5 | Custodian: 10 |
Individual: 138 | Joint: 82 |
Tenants_By_Entirety: 0 | Tenants_In_Common: 1 | Trust: 82

Each of the text items above is a linkbutton. However, I
want to disable the linkbutton if the count is zero.
Hence, I have the following code in my
DataList1.ItemDataBound event:



Dim lblCount As Label = DirectCast(e.Item.FindControl
("lblCount"), Label)

Dim lbtnReg2 As LinkButton = DirectCast
(e.Item.FindControl("lbtnReg2"), LinkButton)



If lblCount.Text = 0 Then

lbtnReg2.Enabled = False

End If




The first time thru, it works fine. The second time thru,
I get the "Object not set to an instance of an object" err
msg. I thought for every item in the datalist, this event
fires. How come it works for the first record, but not
subsequent records?

btw, the RepeatDirection is set to Horizontal and the
RepeatColumns is 5...

I'd appreciate any help...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top