Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
Am using 2.0 (VB), I would like to call a text box in the details view control i.e

asp code
  <asp:TextBox ID="tdate1" runat="server" Text='<%# Bind("To_Date") %>'></asp:TextBox>
  <asp:TextBox ID="fdate2" runat="server" Text='<%# Bind("From_Date") %>'></asp:TextBox>

vb code
Dim tdate, fdate As Date
'Where tdate1 &fdate2 are controlID's in the detailsview
tdate =
fdate =
Dim ts As TimeSpan = tdate.Subtract(fdate)

Your help will be appreciated.

Updated 26-Jan-11 18:43pm
Sandeep Mewara 26-Jan-11 10:40am    
Question not clear.
larsh from Nairobi 27-Jan-11 0:35am    
Actually what am asking is in the code behind page (vb),
How do I refer to a text box in the details view control?

JF2015 27-Jan-11 0:43am    
Edited to fix code formatting.
Ankur\m/ 27-Jan-11 2:34am    
If you are referring an answer, the comment should go below the answer for the answerer to get notified about it.

1 solution

Ok. Did you try something like:
Dim tempTxtSome As TextBox = CType(myDetailView.FindControl("txtSome"), TextBox)

This line of code is at the time when you are accessing record-by-record.

Similar thread discussion here.[^]
Share this answer
Ankur\m/ 27-Jan-11 2:33am    
OP wrote:

Thanks a lot for the help guys, But I still have a small problem. This is the error am getting at the text box declaration "Object reference not set to an instance of an object." How do I go about it?
Enter your reply below and click the Submit button.
Sandeep Mewara 27-Jan-11 2:34am    
Use VS debugged and see what is NULL and you need to make sure that it is initialized properly before using.
larsh from Nairobi 27-Jan-11 3:54am    
Thanks I finally found a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900