Changing properties of a control within an emptydatatemplate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ranger979
    New Member
    • Nov 2008
    • 2

    Changing properties of a control within an emptydatatemplate

    I am using the emptydatatempla te for a gridview control. I have a detailsview control within the emptydatatempla te. In the detailsview I have another templatefield that contains an imagebutton control and a textbox control.

    Code:
                <EmptyDataTemplate>
                    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ActivityTypeControl_ID"
                        DataSourceID="spListActivityTypeControlByType" DefaultMode="Insert" Height="50px"
                        Width="125px" BackColor="#090AAAA" OnPageIndexChanging="DetailsView1_PageIndexChanging1" BorderStyle="None" GridLines="None" OnItemCommand="DetailsView1_ItemCommand">
                        <Fields>
                           <asp:TemplateField HeaderText="Begin Date" SortExpression="BeginDate">
                                <InsertItemTemplate>
                                    &nbsp;<asp:TextBox ID="txtIBeginDate" runat="server" Text='<%# Bind("BeginDate") %>' Width="90px"></asp:TextBox>
                                    <asp:ImageButton ID="imgbutICalendar1" runat="server" ImageUrl="~/Images/APPTL.ICO" Height="16px" 
                                    Width="16px" OnClick="imgbutCalendar_Click" />
                                </InsertItemTemplate>
                            </asp:TemplateField>
                     </asp:DetailsView>
                </EmptyDataTemplate>
    When the user clicks on the imagebutton I look at the text in the textbox and display a calendar control.

    Code:
        Protected Sub imgbutCalendar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
            Const cPROCEDURE = "imgbutCalendar_Click"
            Try
                Session("GrandParentControl") = DirectCast(sender, Control).Parent.Parent
                ClickedControl = DirectCast(sender, Control)
                ParentControl = DirectCast(sender, Control).Parent
                GrandParentControl = DirectCast(sender, Control).Parent.Parent
                Session("imgbutCalendarClicked") = DirectCast(sender, ImageButton)
                Select Case Session("imgbutCalendarClicked").ID.ToString
                    Case "imgbutCalendar1", "imgbutICalendar1"
                        If Session("imgbutCalendarClicked").ID.ToString = "imgbutCalendar1" Then
                            Session("strDateTextBox") = "txtBeginDate"
                        Else
                            Session("strDateTextBox") = "txtIBeginDate"
                        End If
                    Case "imgbutCalendar2", "imgbutICalendar2"
                        If Session("imgbutCalendarClicked").ID.ToString = "imgbutCalendar2" Then
                            Session("strDateTextBox") = "txtEndDate"
                        Else
                            Session("strDateTextBox") = "txtIEndDate"
                        End If
                End Select
                ShowCalendar()
    
            Catch ex As Exception
                clsUtilities.ErrorHandler(cMODULE, cPROCEDURE, ex)
                If Not ex.Message = "Thread was being aborted." Then
                    Response.Redirect("ErrorPage.aspx", True)
                End If
            End Try
        End Sub
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Where do we begin?

    First: Please don't double post.
    You created this once at 5:34am [thread 851919],
    then again at 5:55 am. [thread 851927]

    Second.: You have asked no question.
    please visit the Posting Guidelines for tips on how to ask questions to get the best help.

    Comment

    Working...