Column at the end of gridview

Last post 05-09-2008 10:25 AM by madkrackerz. 2 replies.

Sort Posts:

  • Column at the end of gridview

    05-09-2008, 8:28 AM
    • Loading...
    • madkrackerz
    • Joined on 05-06-2008, 11:31 AM
    • Posts 8

    HI all. I am working on a web site that i need to dynamically add menus to a start page depending on if that user has permission to view the menu or not. So i create the menus and put them in a gridview, if the user does not have permission for that menu, I hide that column in the gridview. It works great the way it is. The only problem is a small column at the end that I can' remove. I think it may be because of the way I get the gridview to display. Any help would be appreciated. BTW I am a noob here, so th emay be another way of displaying this as well. I am open to suggestions. Thanks. here is the code.

    ''THIS is just to get the gridview to render on pageload

    Dim arrMenu As New ArrayList

    arrMenu.Add("1")

    gvMenu.DataSource = arrMenu

    gvMenu.DataBind()

    'Add Menus to grid

     

    Dim cell As New TableCell

    gvMenu.Rows(0).Cells.Add(cell)

    gvMenu.Rows(0).Cells(0).Controls.Add(mnuAdmin)

    gvMenu.Rows(0).Cells.Add(cell)

    gvMenu.Rows(0).Cells(1).Controls.Add(mnuCS)

    gvMenu.Rows(0).Cells.Add(cell)

    gvMenu.Rows(0).Cells(2).Controls.Add(mnuTransaction)

    gvMenu.Rows(0).Cells.Add(cell)

    gvMenu.Rows(0).Cells(3).Controls.Add(mnuItem)

    gvMenu.Rows(0).Cells.Add(cell)

    gvMenu.Rows(0).Cells(4).Controls.Add(mnuInventory)

     

    If there is a way to put these controls i a datatable, I could try that too. I just couldn't figure it out.

  • Re: Column at the end of gridview

    05-09-2008, 8:52 AM
    Answer
    • Loading...
    • nmgomes
    • Joined on 04-09-2007, 11:53 PM
    • Portugal
    • Posts 214
    Hi,

    Why don't you try to use the asp:menu control together with the asp:sitemapdatasource control.

    It could be something like: 

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
    
    <asp:Menu runat="server" ID="TopNavRepeat" DataSourceID="SiteMapDataSource1" ></asp:Menu>
    
      
    Nuno Gomes [visit my blog]
    Portugal - Europe's West Coast
    [Don't forget to click "Mark as Answer" on the post(s) that helped you.]
  • Re: Column at the end of gridview

    05-09-2008, 10:25 AM
    Answer
    • Loading...
    • madkrackerz
    • Joined on 05-06-2008, 11:31 AM
    • Posts 8

    Well I finally figured it out. Thanks for the reply nmgomes, but I could not do it that way. I ended up making a datatable and added a blank row to it, bound it to the gridview, then added the control to the cells. It worked just fine, no little column at the end of the gridview. Then I chose to autoformat the grid like I had done previously. Guess what the little column came back. Jeez! So I took off auto format and applied the colors I wanted.All is well now. THnaks alot.

Page 1 of 1 (3 items)