Composit control with Listbox problem

Discussion in 'ASP .Net' started by SAL, Sep 14, 2009.

  1. SAL

    SAL Guest

    Hi,
    I am developing a composit control (inheriting from that class) that uses
    another class that inherits from ListBox.
    My composite control has a value called GridViewID which takes the id of a
    GridView and if it is not null, takes the columns and lists them in the
    listbox so the user can select which columns to export (to a CSV file for
    Excel).

    When my composit control load, it's executing the code that adds the items
    to the listbox but the items are not showing up on the page that hosts the
    composite control. It's probably something very simple but I can't seem to
    make the items display in the listbox.

    P.S. there's not much error checking in the code yet as I'm just trying to
    get the items in the list to display at this point. Any help is much
    appreciated.

    Here's my CreateChildControls override:
    Protected Overrides Sub CreateChildControls()
    Controls.Clear()
    list = New ExportColumnsList
    list.ID = "lstExport"
    list.GridviewID = Me.GridviewID
    list.ContainerPanelID = Me.ContainerPanelID
    btnSubmit = New Button()
    btnSubmit.ID = "btnSubmit"
    btnSubmit.Text = ButtonText
    AddHandler btnSubmit.Click, AddressOf btnSubmit_Click
    Me.Controls.Add(list)
    Me.Controls.Add(btnSubmit)
    End Sub

    Protected Overrides Sub RecreateChildControls()
    EnsureChildControls()
    End Sub

    Private Sub ColumnExportTool_PreRender(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.PreRender
    LoadList()
    End Sub

    Protected Sub LoadList()
    If ContainerPanelID <> String.Empty Then
    If GridviewID <> String.Empty Then
    list.GetGVInContainer(GridviewID, ContainerPanelID)
    End If
    ElseIf GridviewID <> String.Empty Then
    list.GetGVColumns(GridviewID)
    End If
    End Sub

    From the ExportColumnList class:

    Protected Friend Sub GetGVColumns(ByVal id As String)
    Dim gv As GridView = Page.FindControl(id)
    GetColumns(gv)
    End Sub

    Protected Friend Sub GetGVInContainer(ByVal gridId As String, ByVal panelId
    As String)
    Dim gv As GridView = Nothing
    Dim ctl As Control = Page.FindControl(panelId)
    If Not ctl Is Nothing Then
    gv = ctl.FindControl(gridId)
    GetColumns(gv)
    End If
    End Sub

    Private Sub GetColumns(ByVal gv As GridView)
    Dim li As ListItem
    If Not gv Is Nothing Then
    Dim dcfc As DataControlFieldCollection
    dcfc = gv.Columns
    For Each dcf As DataControlField In dcfc
    If dcf.Visible Then
    li = New ListItem
    li.Text = dcf.HeaderText
    li.Value = dcf.SortExpression
    Items.Add(li)
    End If
    Next
    End If
    End Sub

    S
     
    SAL, Sep 14, 2009
    #1
    1. Advertising

  2. Hi,

    >When my composit control load, it's executing the code that adds the items
    >to the listbox but the items are not showing up on the page that hosts the
    >composite control. It's probably something very simple but I can't seem to
    >make the items display in the listbox.


    I'm willing to help but I think I need a repro project to troubleshoot this
    issue.

    Could you send me a demo that can reproduce this problem? My email is
    se update here after sending the project in case I
    missed that email.

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Allen Chen [MSFT], Sep 15, 2009
    #2
    1. Advertising

  3. SAL

    SAL Guest

    Allen,
    thank you. I've send you a couple of projects that repro the issue.

    SAL

    "Allen Chen [MSFT]" <> wrote in message
    news:...
    > Hi,
    >
    >>When my composit control load, it's executing the code that adds the items
    >>to the listbox but the items are not showing up on the page that hosts the
    >>composite control. It's probably something very simple but I can't seem to
    >>make the items display in the listbox.

    >
    > I'm willing to help but I think I need a repro project to troubleshoot
    > this
    > issue.
    >
    > Could you send me a demo that can reproduce this problem? My email is
    > se update here after sending the project in case
    > I
    > missed that email.
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 2 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions. Issues of this
    > nature are best handled working with a dedicated Microsoft Support
    > Engineer
    > by contacting Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    SAL, Sep 15, 2009
    #3
  4. Howdy!

    One of the major issues is that you should be using "MyBase", not "Me" and
    "MyBase.Controls.Clear()" instead of just "Controls.Clear()".

    Example:

    Protected Overrides Sub CreateChildControls()
    MyBase.Controls.Clear()
    <Other stuff>
    MyBase.Controls.Add(list)
    MyBase.Controls.Add(btnSubmit)
    End Sub

    Hope that helps!

    William

    "SAL" <> wrote in message
    news:...
    > Hi,
    > I am developing a composit control (inheriting from that class) that uses
    > another class that inherits from ListBox.
    > My composite control has a value called GridViewID which takes the id of a
    > GridView and if it is not null, takes the columns and lists them in the
    > listbox so the user can select which columns to export (to a CSV file for
    > Excel).
    >
    > When my composit control load, it's executing the code that adds the items
    > to the listbox but the items are not showing up on the page that hosts the
    > composite control. It's probably something very simple but I can't seem to
    > make the items display in the listbox.
    >
    > P.S. there's not much error checking in the code yet as I'm just trying to
    > get the items in the list to display at this point. Any help is much
    > appreciated.
    >
    > Here's my CreateChildControls override:
    > Protected Overrides Sub CreateChildControls()
    > Controls.Clear()
    > list = New ExportColumnsList
    > list.ID = "lstExport"
    > list.GridviewID = Me.GridviewID
    > list.ContainerPanelID = Me.ContainerPanelID
    > btnSubmit = New Button()
    > btnSubmit.ID = "btnSubmit"
    > btnSubmit.Text = ButtonText
    > AddHandler btnSubmit.Click, AddressOf btnSubmit_Click
    > Me.Controls.Add(list)
    > Me.Controls.Add(btnSubmit)
    > End Sub
    >
    > Protected Overrides Sub RecreateChildControls()
    > EnsureChildControls()
    > End Sub
    >
    > Private Sub ColumnExportTool_PreRender(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.PreRender
    > LoadList()
    > End Sub
    >
    > Protected Sub LoadList()
    > If ContainerPanelID <> String.Empty Then
    > If GridviewID <> String.Empty Then
    > list.GetGVInContainer(GridviewID, ContainerPanelID)
    > End If
    > ElseIf GridviewID <> String.Empty Then
    > list.GetGVColumns(GridviewID)
    > End If
    > End Sub
    >
    > From the ExportColumnList class:
    >
    > Protected Friend Sub GetGVColumns(ByVal id As String)
    > Dim gv As GridView = Page.FindControl(id)
    > GetColumns(gv)
    > End Sub
    >
    > Protected Friend Sub GetGVInContainer(ByVal gridId As String, ByVal
    > panelId As String)
    > Dim gv As GridView = Nothing
    > Dim ctl As Control = Page.FindControl(panelId)
    > If Not ctl Is Nothing Then
    > gv = ctl.FindControl(gridId)
    > GetColumns(gv)
    > End If
    > End Sub
    >
    > Private Sub GetColumns(ByVal gv As GridView)
    > Dim li As ListItem
    > If Not gv Is Nothing Then
    > Dim dcfc As DataControlFieldCollection
    > dcfc = gv.Columns
    > For Each dcf As DataControlField In dcfc
    > If dcf.Visible Then
    > li = New ListItem
    > li.Text = dcf.HeaderText
    > li.Value = dcf.SortExpression
    > Items.Add(li)
    > End If
    > Next
    > End If
    > End Sub
    >
    > S
    >
     
    William Niver, Sep 15, 2009
    #4
  5. Hi Steve,

    >thank you. I've send you a couple of projects that repro the issue.


    Thanks for your project. Please set breakpoints to debug in the following
    method:

    Private Sub GetColumns(ByVal gv As GridView)
    Dim li As ListItem

    If Not gv Is Nothing Then
    Dim dcfc As DataControlFieldCollection
    dcfc = gv.Columns
    For Each dcf As DataControlField In dcfc
    If dcf.Visible Then
    li = New ListItem
    li.Text = dcf.HeaderText

    li.Value = dcf.SortExpression
    Items.Add(li)
    End If
    Next
    End If
    End Sub

    If you check the value of gv.Columns.Count, you probably will see it's 0.
    This is because the auto-generated columns of GridView is not added in the
    Columns collection of GridView. Only explicitly specified columns like
    below are added into the collection. For example, the following code will
    create two columns. However, GridView1.Columns.Count is 1.

    <asp:GridView ID="GridView1" runat="server"
    DataSourceID="ObjectDataSource1">
    <Columns><asp:TemplateField HeaderText="Header">
    <ItemTemplate>
    <%#Container.DataItem %>
    </ItemTemplate></asp:TemplateField></Columns>
    </asp:GridView>

    Another issue is the following two lines:

    li.Text = dcf.HeaderText

    li.Value = dcf.SortExpression

    If you want to show some text in the ListBox, the dcf.HeaderText should not
    be empty string. However, if you don't specify the HeaderText for, say, in
    above code, TemplateField, you'll get empty string here. It's common
    because developers can use HeaderTemplate to customize the Header.Therefore
    you cannot see anything shown in the ListBox. The same to
    dcf.SortExpression. If it's not specified, you'll get empty string.

    So if you want to do so you probably need to change your code logic. For
    instance you can try this way to get controls in GridView:

    GridView.Controls(0) ------ Table

    GridView.Controls(0).Controls(index) ------ GridViewRow

    GridView.Controls(0).Controls(index).Controls(index) ------ TableCell. For
    BoundField, we can use TableCell.Text to get the value.

    GridView.Controls(0).Controls(index).Controls(index).Controls(index) ------
    Controls in the TableCell

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .
     
    Allen Chen [MSFT], Sep 16, 2009
    #5
  6. SAL

    SAL Guest

    Allen,
    thank you for your response. In the gridview I'm using in my test project,
    the columns are not auto generated and I have set a break point in the
    routine you suggested. It's showing the text of the header and sort
    expression.

    The other issue:
    I knew that using the DatControlField to get this information could possibly
    be problematic. However, I wasn't sure how to detect if I had a templated
    field or not. I'll study your ideas for implementation.

    Are you able to get items into the ListBox?

    SAL

    "Allen Chen [MSFT]" <> wrote in message
    news:...
    > Hi Steve,
    >
    >>thank you. I've send you a couple of projects that repro the issue.

    >
    > Thanks for your project. Please set breakpoints to debug in the following
    > method:
    >
    > Private Sub GetColumns(ByVal gv As GridView)
    > Dim li As ListItem
    >
    > If Not gv Is Nothing Then
    > Dim dcfc As DataControlFieldCollection
    > dcfc = gv.Columns
    > For Each dcf As DataControlField In dcfc
    > If dcf.Visible Then
    > li = New ListItem
    > li.Text = dcf.HeaderText
    >
    > li.Value = dcf.SortExpression
    > Items.Add(li)
    > End If
    > Next
    > End If
    > End Sub
    >
    > If you check the value of gv.Columns.Count, you probably will see it's 0.
    > This is because the auto-generated columns of GridView is not added in the
    > Columns collection of GridView. Only explicitly specified columns like
    > below are added into the collection. For example, the following code will
    > create two columns. However, GridView1.Columns.Count is 1.
    >
    > <asp:GridView ID="GridView1" runat="server"
    > DataSourceID="ObjectDataSource1">
    > <Columns><asp:TemplateField HeaderText="Header">
    > <ItemTemplate>
    > <%#Container.DataItem %>
    > </ItemTemplate></asp:TemplateField></Columns>
    > </asp:GridView>
    >
    > Another issue is the following two lines:
    >
    > li.Text = dcf.HeaderText
    >
    > li.Value = dcf.SortExpression
    >
    > If you want to show some text in the ListBox, the dcf.HeaderText should
    > not
    > be empty string. However, if you don't specify the HeaderText for, say, in
    > above code, TemplateField, you'll get empty string here. It's common
    > because developers can use HeaderTemplate to customize the
    > Header.Therefore
    > you cannot see anything shown in the ListBox. The same to
    > dcf.SortExpression. If it's not specified, you'll get empty string.
    >
    > So if you want to do so you probably need to change your code logic. For
    > instance you can try this way to get controls in GridView:
    >
    > GridView.Controls(0) ------ Table
    >
    > GridView.Controls(0).Controls(index) ------ GridViewRow
    >
    > GridView.Controls(0).Controls(index).Controls(index) ------ TableCell. For
    > BoundField, we can use TableCell.Text to get the value.
    >
    > GridView.Controls(0).Controls(index).Controls(index).Controls(index) ------
    > Controls in the TableCell
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
     
    SAL, Sep 16, 2009
    #6
  7. SAL

    SAL Guest

    William,
    thank you for your suggestion. I'll change the code.

    SAL

    "William Niver" <> wrote in message
    news:...
    >
    > Howdy!
    >
    > One of the major issues is that you should be using "MyBase", not "Me" and
    > "MyBase.Controls.Clear()" instead of just "Controls.Clear()".
    >
    > Example:
    >
    > Protected Overrides Sub CreateChildControls()
    > MyBase.Controls.Clear()
    > <Other stuff>
    > MyBase.Controls.Add(list)
    > MyBase.Controls.Add(btnSubmit)
    > End Sub
    >
    > Hope that helps!
    >
    > William
    >
    > "SAL" <> wrote in message
    > news:...
    >> Hi,
    >> I am developing a composit control (inheriting from that class) that uses
    >> another class that inherits from ListBox.
    >> My composite control has a value called GridViewID which takes the id of
    >> a GridView and if it is not null, takes the columns and lists them in the
    >> listbox so the user can select which columns to export (to a CSV file for
    >> Excel).
    >>
    >> When my composit control load, it's executing the code that adds the
    >> items to the listbox but the items are not showing up on the page that
    >> hosts the composite control. It's probably something very simple but I
    >> can't seem to make the items display in the listbox.
    >>
    >> P.S. there's not much error checking in the code yet as I'm just trying
    >> to get the items in the list to display at this point. Any help is much
    >> appreciated.
    >>
    >> Here's my CreateChildControls override:
    >> Protected Overrides Sub CreateChildControls()
    >> Controls.Clear()
    >> list = New ExportColumnsList
    >> list.ID = "lstExport"
    >> list.GridviewID = Me.GridviewID
    >> list.ContainerPanelID = Me.ContainerPanelID
    >> btnSubmit = New Button()
    >> btnSubmit.ID = "btnSubmit"
    >> btnSubmit.Text = ButtonText
    >> AddHandler btnSubmit.Click, AddressOf btnSubmit_Click
    >> Me.Controls.Add(list)
    >> Me.Controls.Add(btnSubmit)
    >> End Sub
    >>
    >> Protected Overrides Sub RecreateChildControls()
    >> EnsureChildControls()
    >> End Sub
    >>
    >> Private Sub ColumnExportTool_PreRender(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles Me.PreRender
    >> LoadList()
    >> End Sub
    >>
    >> Protected Sub LoadList()
    >> If ContainerPanelID <> String.Empty Then
    >> If GridviewID <> String.Empty Then
    >> list.GetGVInContainer(GridviewID, ContainerPanelID)
    >> End If
    >> ElseIf GridviewID <> String.Empty Then
    >> list.GetGVColumns(GridviewID)
    >> End If
    >> End Sub
    >>
    >> From the ExportColumnList class:
    >>
    >> Protected Friend Sub GetGVColumns(ByVal id As String)
    >> Dim gv As GridView = Page.FindControl(id)
    >> GetColumns(gv)
    >> End Sub
    >>
    >> Protected Friend Sub GetGVInContainer(ByVal gridId As String, ByVal
    >> panelId As String)
    >> Dim gv As GridView = Nothing
    >> Dim ctl As Control = Page.FindControl(panelId)
    >> If Not ctl Is Nothing Then
    >> gv = ctl.FindControl(gridId)
    >> GetColumns(gv)
    >> End If
    >> End Sub
    >>
    >> Private Sub GetColumns(ByVal gv As GridView)
    >> Dim li As ListItem
    >> If Not gv Is Nothing Then
    >> Dim dcfc As DataControlFieldCollection
    >> dcfc = gv.Columns
    >> For Each dcf As DataControlField In dcfc
    >> If dcf.Visible Then
    >> li = New ListItem
    >> li.Text = dcf.HeaderText
    >> li.Value = dcf.SortExpression
    >> Items.Add(li)
    >> End If
    >> Next
    >> End If
    >> End Sub
    >>
    >> S
    >>

    >
     
    SAL, Sep 16, 2009
    #7
  8. SAL

    SAL Guest

    Okay, so I've made some of the suggested changes to my code, i.e., change
    me.contorls.add to MyBase.Controls.Add. I have not changed the code to what
    Allen suggested because my gridview's columns collection is not empty, the
    HeaderText is not empty and the SortExpression is not empty. I realize that
    I'll need to change the way that I'm getting the text for the column, the
    way the text appears in the gridview and the actually column from the data
    source differently than I am now. I'm just trying to get stuff to show up in
    the ListBox right now.

    I also overrode the OnPreRender method of the CompositControl but the
    listbox is still not displaying the text. Any help on getting the Listbox to
    display the text I'm asking it to display would be very helpful. Heck, at
    this point I could even hard code some text in there and it wouldn't display
    so I'm still doing something wrong on this...
    Thanks in advance for any help I recieve. I truely appreciate it.

    Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
    LoadList()
    MyBase.OnPreRender(e)
    End Sub

    SAL

    "SAL" <> wrote in message
    news:...
    > Hi,
    > I am developing a composit control (inheriting from that class) that uses
    > another class that inherits from ListBox.
    > My composite control has a value called GridViewID which takes the id of a
    > GridView and if it is not null, takes the columns and lists them in the
    > listbox so the user can select which columns to export (to a CSV file for
    > Excel).
    >
    > When my composit control load, it's executing the code that adds the items
    > to the listbox but the items are not showing up on the page that hosts the
    > composite control. It's probably something very simple but I can't seem to
    > make the items display in the listbox.
    >
    > P.S. there's not much error checking in the code yet as I'm just trying to
    > get the items in the list to display at this point. Any help is much
    > appreciated.
    >
    > Here's my CreateChildControls override:
    > Protected Overrides Sub CreateChildControls()
    > Controls.Clear()
    > list = New ExportColumnsList
    > list.ID = "lstExport"
    > list.GridviewID = Me.GridviewID
    > list.ContainerPanelID = Me.ContainerPanelID
    > btnSubmit = New Button()
    > btnSubmit.ID = "btnSubmit"
    > btnSubmit.Text = ButtonText
    > AddHandler btnSubmit.Click, AddressOf btnSubmit_Click
    > Me.Controls.Add(list)
    > Me.Controls.Add(btnSubmit)
    > End Sub
    >
    > Protected Overrides Sub RecreateChildControls()
    > EnsureChildControls()
    > End Sub
    >
    > Private Sub ColumnExportTool_PreRender(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.PreRender
    > LoadList()
    > End Sub
    >
    > Protected Sub LoadList()
    > If ContainerPanelID <> String.Empty Then
    > If GridviewID <> String.Empty Then
    > list.GetGVInContainer(GridviewID, ContainerPanelID)
    > End If
    > ElseIf GridviewID <> String.Empty Then
    > list.GetGVColumns(GridviewID)
    > End If
    > End Sub
    >
    > From the ExportColumnList class:
    >
    > Protected Friend Sub GetGVColumns(ByVal id As String)
    > Dim gv As GridView = Page.FindControl(id)
    > GetColumns(gv)
    > End Sub
    >
    > Protected Friend Sub GetGVInContainer(ByVal gridId As String, ByVal
    > panelId As String)
    > Dim gv As GridView = Nothing
    > Dim ctl As Control = Page.FindControl(panelId)
    > If Not ctl Is Nothing Then
    > gv = ctl.FindControl(gridId)
    > GetColumns(gv)
    > End If
    > End Sub
    >
    > Private Sub GetColumns(ByVal gv As GridView)
    > Dim li As ListItem
    > If Not gv Is Nothing Then
    > Dim dcfc As DataControlFieldCollection
    > dcfc = gv.Columns
    > For Each dcf As DataControlField In dcfc
    > If dcf.Visible Then
    > li = New ListItem
    > li.Text = dcf.HeaderText
    > li.Value = dcf.SortExpression
    > Items.Add(li)
    > End If
    > Next
    > End If
    > End Sub
    >
    > S
    >
     
    SAL, Sep 16, 2009
    #8
  9. Hi Steve,

    >Are you able to get items into the ListBox?


    Yes I am. I've sent you an email with a working sample. In the ListBox you
    can see the header. Could you compare your code with mine to see what the
    difference is?


    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .
     
    Allen Chen [MSFT], Sep 17, 2009
    #9
  10. Hi Steve,

    >Are you able to get items into the ListBox?


    Do you have any progress on this issue? I've sent two emails to you but got
    no reply so far. Please update here if it still doesn't work.


    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .
     
    Allen Chen [MSFT], Sep 24, 2009
    #10
  11. SAL

    SAL Guest

    Hi Allen,
    I sent you a screen shot and the project back again.

    S

    "Allen Chen [MSFT]" <> wrote in message
    news:...
    > Hi Steve,
    >
    >>Are you able to get items into the ListBox?

    >
    > Do you have any progress on this issue? I've sent two emails to you but
    > got
    > no reply so far. Please update here if it still doesn't work.
    >
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
     
    SAL, Sep 25, 2009
    #11
  12. SAL

    SAL Guest

    As it turns out, this is an IE 7 rendering issue. Firefox renders the
    control fine. I very much appreciate Allen's support on this issue. However,
    I must express my dissatisfaction with IE, once again. Wasn't IE 7 supposed
    to solve many of these rendering issues? The issue being that I was
    specifying the width in the Render routine for the listbox at 100% (of the
    td tag) rather than an absolute value. I'm told that IE 8 has resolved this
    issue. However, our entire company just moved to IE 7 with little to no
    chance of getting us to move to IE 8 at this time. Okay, so maybe this is a
    rant and maybe I'm just being lazy by not checking which browser the client
    is using.
    If I'm not mistaken and I remember correctly, Firefox can have issues if you
    specify an abosolute value for some controls. I have not tested this last
    issue on the listbox however.
    Okay, I guess I'm done with my rant now and I hope this post helps someone
    else down the road.

    Thanks again Allen for your support.

    S

    "William Niver" <> wrote in message
    news:...
    >
    > Howdy!
    >
    > One of the major issues is that you should be using "MyBase", not "Me" and
    > "MyBase.Controls.Clear()" instead of just "Controls.Clear()".
    >
    > Example:
    >
    > Protected Overrides Sub CreateChildControls()
    > MyBase.Controls.Clear()
    > <Other stuff>
    > MyBase.Controls.Add(list)
    > MyBase.Controls.Add(btnSubmit)
    > End Sub
    >
    > Hope that helps!
    >
    > William
    >
    > "SAL" <> wrote in message
    > news:...
    >> Hi,
    >> I am developing a composit control (inheriting from that class) that uses
    >> another class that inherits from ListBox.
    >> My composite control has a value called GridViewID which takes the id of
    >> a GridView and if it is not null, takes the columns and lists them in the
    >> listbox so the user can select which columns to export (to a CSV file for
    >> Excel).
    >>
    >> When my composit control load, it's executing the code that adds the
    >> items to the listbox but the items are not showing up on the page that
    >> hosts the composite control. It's probably something very simple but I
    >> can't seem to make the items display in the listbox.
    >>
    >> P.S. there's not much error checking in the code yet as I'm just trying
    >> to get the items in the list to display at this point. Any help is much
    >> appreciated.
    >>
    >> Here's my CreateChildControls override:
    >> Protected Overrides Sub CreateChildControls()
    >> Controls.Clear()
    >> list = New ExportColumnsList
    >> list.ID = "lstExport"
    >> list.GridviewID = Me.GridviewID
    >> list.ContainerPanelID = Me.ContainerPanelID
    >> btnSubmit = New Button()
    >> btnSubmit.ID = "btnSubmit"
    >> btnSubmit.Text = ButtonText
    >> AddHandler btnSubmit.Click, AddressOf btnSubmit_Click
    >> Me.Controls.Add(list)
    >> Me.Controls.Add(btnSubmit)
    >> End Sub
    >>
    >> Protected Overrides Sub RecreateChildControls()
    >> EnsureChildControls()
    >> End Sub
    >>
    >> Private Sub ColumnExportTool_PreRender(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles Me.PreRender
    >> LoadList()
    >> End Sub
    >>
    >> Protected Sub LoadList()
    >> If ContainerPanelID <> String.Empty Then
    >> If GridviewID <> String.Empty Then
    >> list.GetGVInContainer(GridviewID, ContainerPanelID)
    >> End If
    >> ElseIf GridviewID <> String.Empty Then
    >> list.GetGVColumns(GridviewID)
    >> End If
    >> End Sub
    >>
    >> From the ExportColumnList class:
    >>
    >> Protected Friend Sub GetGVColumns(ByVal id As String)
    >> Dim gv As GridView = Page.FindControl(id)
    >> GetColumns(gv)
    >> End Sub
    >>
    >> Protected Friend Sub GetGVInContainer(ByVal gridId As String, ByVal
    >> panelId As String)
    >> Dim gv As GridView = Nothing
    >> Dim ctl As Control = Page.FindControl(panelId)
    >> If Not ctl Is Nothing Then
    >> gv = ctl.FindControl(gridId)
    >> GetColumns(gv)
    >> End If
    >> End Sub
    >>
    >> Private Sub GetColumns(ByVal gv As GridView)
    >> Dim li As ListItem
    >> If Not gv Is Nothing Then
    >> Dim dcfc As DataControlFieldCollection
    >> dcfc = gv.Columns
    >> For Each dcf As DataControlField In dcfc
    >> If dcf.Visible Then
    >> li = New ListItem
    >> li.Text = dcf.HeaderText
    >> li.Value = dcf.SortExpression
    >> Items.Add(li)
    >> End If
    >> Next
    >> End If
    >> End Sub
    >>
    >> S
    >>

    >
     
    SAL, Sep 29, 2009
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    1,055
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    408
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    883
    Andrew de la Harpe
    May 3, 2004
  4. BB
    Replies:
    1
    Views:
    493
    Mohamed Zied Nouira
    Nov 16, 2005
  5. MartinL

    Rendering non-composit Control

    MartinL, Nov 12, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    118
    Guest
    Nov 13, 2003
Loading...

Share This Page