Hi all,
I am having major difficulty with the following. I have an aspx page with a reference to an ascx user control. The code for the control is as follows:
The code behind file test.ascx.vb is as follows:
I can get/set the text on the button btnVote but I am unable to access the RadioButtonList. I cannot get the SelectedItem value. I am getting Object reference not set errors.
I have tried many different suggestions I found on other sites but nothing seems to work.
Any advice would be greatly appreciated.
Thanks
I am having major difficulty with the following. I have an aspx page with a reference to an ascx user control. The code for the control is as follows:
Code:
<%@ Control Language="vb" Inherits="myUserControl" Src="../../codeBehind/test.aspx.vb" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="FI_OpinionPoll"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_FI_DBConn") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_FI_DBConn") %>'
CommandText='<%# "SELECT FI_Poll.FI_PollId, FI_Poll.FI_PollTitle, FI_Poll.FI_TotalVotes, FI_Poll.FI_NumPollOptions, FI_PollOptions.FI_OptionText, FI_PollOptions.FI_OptionVotes, FI_PollOptions.FI_PollId_Fk, FI_PollOptions.FI_PollOptionId FROM FI_Poll, FI_PollOptions WHERE FI_PollOptions.FI_PollId_Fk = (SELECT MAX(FI_Poll.FI_PollId) FROM FI_Poll)" %>'
Debug="true">
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div class="panel" id="poll_input" style="display: block;">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="right_frame_userlogin">
<tr>
<td colspan="3" align="center">
<strong><%# FI_OpinionPoll.FieldValue("FI_PollTitle", Container) %></strong>
<asp:Label ID="lblOpinionId" runat="server" Visible="false" Text='<%# FI_OpinionPoll.FieldValue("FI_PollId", Container) %>'></asp:Label>
</td>
</tr>
<tr>
<td height="4" colspan="3"></td>
</tr>
<tr>
<td width="2%"></td>
<td></td>
<td width="2%"></td>
</tr>
<tr>
<td width="2%"></td>
<td width="80%">
<asp:RadioButtonList ID="aaa" CellPadding="0" CellSpacing="0" CssClass="right_frame_table" DataSource="<%# FI_OpinionPoll.DefaultView %>" DataTextField="FI_OptionText" DataValueField="FI_PollOptionId" runat="server" RepeatDirection="Vertical" RepeatLayout="table" TextAlign="right" OnSelectedIndexChanged="changed" AutoPostBack="true"></asp:RadioButtonList>
</td>
<td width="2%"></td>
</tr>
<tr>
<td colspan="3" height="4"></td>
</tr>
<tr>
<td height="4" colspan="3"></td>
</tr>
<tr>
<td colspan="3">
<asp:Button ID="btnVote" runat="server" Text="Vote" OnClick="vote_Click" />
</td>
</tr>
<tr>
<td height="4" colspan="3"></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
The code behind file test.ascx.vb is as follows:
Code:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.OleDB
Public Class myUserControl : Inherits UserControl
Protected btnVote As Button
Protected aaa As RadioButtonList
Protected lblOpinionId as Label
Public Sub vote_Click(sender As Object, e As EventArgs)
Dim optionSelected As String
btnVote.Text = "test"
End Sub
Public Sub changed(sender As Object, e As EventArgs)
btnVote.Text = aaa.SelectedItem.Text
End Sub
End Class
I can get/set the text on the button btnVote but I am unable to access the RadioButtonList. I cannot get the SelectedItem value. I am getting Object reference not set errors.
I have tried many different suggestions I found on other sites but nothing seems to work.
Any advice would be greatly appreciated.
Thanks