Can't Find My Controls

J

Joe

Hi,

I have an ASP.NET web page with a radio button list on it.
When I go to the .vb code behind module and attempt to reference the
radio button list, it tells me that the control does not exist. My
aspx code is below:

<InsertItemTemplate>
<table border="1">
..........
<tr>
<td> <asp:RadioButtonList ID="rbtnNewEstimate"
runat="server" AutoPostBack="True" >
<asp:ListItem>Create A New Estimate </
asp:ListItem>
<asp:ListItem>Create A New Estimate, Based On An
Existing Estimate</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>

In my VB code I am attempting to do this

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
rbtnNewEstimate.Checked = ......
End Sub

But it cannot see rbtnNewEstimate. Can anyone tell me why my VB
page does not "see" the controls on my web page?
 
J

Joe

Hi,

         I have an ASP.NET web page with a radio button list on it.
When I go to the .vb code behind module and attempt to reference the
radio button list, it tells me that the control does not exist.   My
aspx code is below:

<InsertItemTemplate>
           <table border="1">
            ..........
             <tr>
               <td> <asp:RadioButtonList ID="rbtnNewEstimate"
runat="server" AutoPostBack="True" >
                      <asp:ListItem>Create A New Estimate </
asp:ListItem>
                      <asp:ListItem>Create A New Estimate, Based On An
Existing Estimate</asp:ListItem>
                    </asp:RadioButtonList>
               </td>
             </tr>
            </table>

In my VB code I am attempting to do this

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
        rbtnNewEstimate.Checked = ......
    End Sub

But it cannot see rbtnNewEstimate.    Can anyone tell me why my VB
page does not "see" the controls on my web page?

I should also add that the controls that I need to access are inside
of a FormView control.
 
R

Rob Hill

It appears that you are using a FormView or some other databound control.

You can reference the control as such:

RadioButtonList rbtnNewEstimate =
(RadioButtonList)MyFormView.FindControl("rbtnNewEstimate");

This is C#, I don't know the VB syntax.

Also, you can create the event in the designer for the
RadioButtonList.Clicked event and it will store this information in the
markup. That's how I do it.

Thanks,

Rob Hill


Hi,

I have an ASP.NET web page with a radio button list on it.
When I go to the .vb code behind module and attempt to reference the
radio button list, it tells me that the control does not exist. My
aspx code is below:

<InsertItemTemplate>
<table border="1">
..........
<tr>
<td> <asp:RadioButtonList ID="rbtnNewEstimate"
runat="server" AutoPostBack="True" >
<asp:ListItem>Create A New Estimate </
asp:ListItem>
<asp:ListItem>Create A New Estimate, Based On An
Existing Estimate</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>

In my VB code I am attempting to do this

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
rbtnNewEstimate.Checked = ......
End Sub

But it cannot see rbtnNewEstimate. Can anyone tell me why my VB
page does not "see" the controls on my web page?

I should also add that the controls that I need to access are inside
of a FormView control.
 
A

Abdul Sami

As you are saying that you are using formview to embed controls then you will
use
in VB
Dim RadioButtonListName As RadiobuttonList =
CType(FormView1.FindControl("RadioButtonListName"), RadiobuttonList)
 

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,037
Messages
2,570,371
Members
47,017
Latest member
TheoTate56

Latest Threads

Top