1

In an ASP.Net VB.Net code-behind file we have this variable:

Public Shared blnTuesdayCheckBoxState As Boolean

We are trying to use the variable for an ASP:ConrolParameter but seem to not have everything set up correctly.

Can you show me what I need to do to correct it?

This is the ASP:ControlParameter being used in an the DataSource markup:

<UpdateParameters>
    <asp:Parameter Name="DayOfWeekMonday" Type="String" />

    <asp:ControlParameter 
        ControlID="blnTuesdayCheckBoxState" 
        Name="DayOfWeekTuesday" 
        PropertyName="Text" 
        Type="String" />

    <asp:Parameter Name="DayOfWeekWednesday" Type="String" />
    <asp:Parameter Name="DayOfWeekThursday" Type="String" />
    <asp:Parameter Name="DayOfWeekFriday" Type="String" />
    <asp:Parameter Name="DayOfWeekSaturday" Type="String" />
    <asp:Parameter Name="DayOfWeekSunday" Type="String" />
    <asp:Parameter Name="StartTime" Type="String" />
    <asp:Parameter Name="EndTime" Type="String" />
    <asp:Parameter Name="ClassID" Type="Int32" />
    <asp:Parameter Name="TeacherID" Type="Int32" />
    <asp:Parameter Name="ID" />
</UpdateParameters>

If we can get DayOfWeekTuesday working, we will do the same for the other days of the week.

In a DetailsView is this ImageButton:

<asp:TemplateField HeaderText="Tuesday:">
    <EditItemTemplate>
        <asp:ImageButton 
            ID="ImageButtonEditDayOfWeekTuesday" 
            runat="server" 
            ImageUrl='<%# getChecked(Eval("DayOfWeekTuesday"))%>' 
            Height="15"
            Width="15" 
            OnClick="ImageButtonDayOfWeekTuesdayEdit_Click" 
            CausesValidation="False">
        </asp:ImageButton>
    </EditItemTemplate>
</asp:TemplateField>

When the user clicks on the ImageButton this code executes to populate the variable:

Protected Sub ImageButtonDayOfWeekTuesdayEdit_Click(sender As Object, e As ImageClickEventArgs)

    '     Dim chkTheCheckBox As New CheckBox
    Dim imgTheImageButton As New ImageButton

    '        chkTheCheckBox = DetailsView.FindControl("CheckBoxEditDayOfWeekTuesday")
    imgTheImageButton = DetailsView.FindControl("ImageButtonEditDayOfWeekTuesday")

    If blnTuesdayCheckBoxState = True Then
        imgTheImageButton.ImageUrl = "../../Images/unchecked.png"

        '           chkTheCheckBox.Checked = False
        blnTuesdayCheckBoxState = False
    Else
        imgTheImageButton.ImageUrl = "../../Images/checked.png"

        '          chkTheCheckBox.Checked = True
        blnTuesdayCheckBoxState = True
    End If
End Sub

The above code simulates the ticking of a CheckBox, only it's an image being used instead of an actual CheckBox.

The original coding that works used to use actual CheckBoxes to store the values to be saved to the database as shown in the commented out code but we want to replace them all with the ImageButtons.

Also if I use an ASP:Label for the ASP:ControlParameter then everything works ok. Since there are 7 days of the week we want to use variables instead of placing many labels on the web page.

Emad-ud-deen
  • 4,734
  • 21
  • 87
  • 152

0 Answers0