Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Remove blank space in datagrid

Remove blank space in datagrid

Scheduled Pinned Locked Moved ASP.NET
csharpcsstutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Software_Guy_123
    wrote on last edited by
    #1

    Hello, We have created user control using data grid in VB.Net. In this datagrid we are dispalying for each row edit and delete icon. If user does not have access then we don't want to display edit & delete icon, but some blank space is coming in place of icons. We don't want this blank space if user does not have access for edit & delete. Can somebody give sample code how to remove that blank space.

    Thanks & Regards, Kumar

    T 2 Replies Last reply
    0
    • S Software_Guy_123

      Hello, We have created user control using data grid in VB.Net. In this datagrid we are dispalying for each row edit and delete icon. If user does not have access then we don't want to display edit & delete icon, but some blank space is coming in place of icons. We don't want this blank space if user does not have access for edit & delete. Can somebody give sample code how to remove that blank space.

      Thanks & Regards, Kumar

      T Offline
      T Offline
      Tuwing Sabado
      wrote on last edited by
      #2

      Hide the Datagrid column instead of hiding the icons, Add the code below on Page_Load. If IsUserHasAddDelEditAccess = False Then 'Hide Columns for Add, Edit and Delete 'Add Column DataGrid1.Columns(10).Visible = False 'Edit Column DataGrid1.Columns(11).Visible = False 'Delete Column DataGrid1.Columns(12).Visible = False End If Regards, Mark

      1 Reply Last reply
      0
      • S Software_Guy_123

        Hello, We have created user control using data grid in VB.Net. In this datagrid we are dispalying for each row edit and delete icon. If user does not have access then we don't want to display edit & delete icon, but some blank space is coming in place of icons. We don't want this blank space if user does not have access for edit & delete. Can somebody give sample code how to remove that blank space.

        Thanks & Regards, Kumar

        T Offline
        T Offline
        Tuwing Sabado
        wrote on last edited by
        #3

        Another Option for you. 1. Add an image and imagebutton to your datagrid add column 2. Set the image visibility to false. this image will represent a user have no access. 3. Override the DataGrid ItemDataBound Event. for your reference see the code below. Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If IsUserHasAddDelEditAccess = False Then Dim imgbAdd As ImageButton = CType(e.Item.Cells(0).FindControl("imgButtonAdd"), ImageButton) imgbAdd.Visible = False Dim imgAddGrey As WebControls.Image = CType(e.Item.Cells(0).FindControl("imgAddGrey"), WebControls.Image) imgAddGrey.Visible = True ' Do the same thing with Edit and Delete End If End Sub Regards, Mark

        S 1 Reply Last reply
        0
        • T Tuwing Sabado

          Another Option for you. 1. Add an image and imagebutton to your datagrid add column 2. Set the image visibility to false. this image will represent a user have no access. 3. Override the DataGrid ItemDataBound Event. for your reference see the code below. Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If IsUserHasAddDelEditAccess = False Then Dim imgbAdd As ImageButton = CType(e.Item.Cells(0).FindControl("imgButtonAdd"), ImageButton) imgbAdd.Visible = False Dim imgAddGrey As WebControls.Image = CType(e.Item.Cells(0).FindControl("imgAddGrey"), WebControls.Image) imgAddGrey.Visible = True ' Do the same thing with Edit and Delete End If End Sub Regards, Mark

          S Offline
          S Offline
          Software_Guy_123
          wrote on last edited by
          #4

          Thanks a lot. First one code is working for us.

          Thanks & Regards, Kumar

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups