Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>this code provide you to hide particular cell from code behind if the value is blank...</p> <pre><code>Protected Sub gvCoreUtilization_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCoreUtilization.RowDataBound Try If e.Row.RowType = DataControlRowType.DataRow Then Dim olblRoleID As New Label Dim olblSupervisorName As New Label Dim olblUserECode As New Label Dim olblUserName As New Label Dim olblDesignation As New Label Dim olblLDTraining As New Label Dim olblNonProduction As New Label Dim olblProcessSupport As New Label Dim olblProcessTraining As New Label Dim olblProduction As New Label Dim olblSystemDowntime As New Label Dim olblGrandTotal As New Label olblRoleID = CType(e.Row.FindControl("lblRoleID"), Label) olblSupervisorName = CType(e.Row.FindControl("lblSupervisorName"), Label) olblUserECode = CType(e.Row.FindControl("lblUserECode"), Label) olblUserName = CType(e.Row.FindControl("lblUserName"), Label) olblDesignation = CType(e.Row.FindControl("lblDesignation"), Label) olblLDTraining = CType(e.Row.FindControl("lblLDTraining"), Label) olblNonProduction = CType(e.Row.FindControl("lblNonProduction"), Label) olblProcessSupport = CType(e.Row.FindControl("lblProcessSupport"), Label) olblProcessTraining = CType(e.Row.FindControl("lblProcessTraining"), Label) olblProduction = CType(e.Row.FindControl("lblProduction"), Label) olblSystemDowntime = CType(e.Row.FindControl("lblSystemDowntime"), Label) olblGrandTotal = CType(e.Row.FindControl("lblGrandTotal"), Label) If CType(DataBinder.Eval(e.Row.DataItem, "RoleId"), String) = "" Then olblRoleID.Visible = False Else olblRoleID.Text = DataBinder.Eval(e.Row.DataItem, "RoleId") End If If CType(DataBinder.Eval(e.Row.DataItem, "SupervisorName"), String) = "" Then olblSupervisorName.Visible = False Else olblSupervisorName.Text = DataBinder.Eval(e.Row.DataItem, "SupervisorName") End If If CType(DataBinder.Eval(e.Row.DataItem, "UserECode"), String) = "" Then olblUserECode.Visible = False Else olblUserECode.Text = DataBinder.Eval(e.Row.DataItem, "UserECode") End If If CType(DataBinder.Eval(e.Row.DataItem, "UserName"), String) = "" Then olblUserName.Visible = False Else olblUserName.Text = DataBinder.Eval(e.Row.DataItem, "UserName") End If If CType(DataBinder.Eval(e.Row.DataItem, "Designation"), String) = "" Then olblDesignation.Visible = False Else olblDesignation.Text = DataBinder.Eval(e.Row.DataItem, "Designation") End If If CType(DataBinder.Eval(e.Row.DataItem, "L &amp; D Training"), String) = "" Then olblLDTraining.Visible = False Else olblLDTraining.Text = DataBinder.Eval(e.Row.DataItem, "L &amp; D Training") End If If CType(DataBinder.Eval(e.Row.DataItem, "Non Production"), String) = "" Then olblNonProduction.Visible = False Else olblNonProduction.Text = DataBinder.Eval(e.Row.DataItem, "Non Production") End If If CType(DataBinder.Eval(e.Row.DataItem, "Process Support"), String) = "" Then olblProcessSupport.Visible = False Else olblProcessSupport.Text = DataBinder.Eval(e.Row.DataItem, "Process Support") End If If CType(DataBinder.Eval(e.Row.DataItem, "Process Training"), String) = "" Then olblProcessTraining.Visible = False Else olblProcessTraining.Text = DataBinder.Eval(e.Row.DataItem, "Process Training") End If If CType(DataBinder.Eval(e.Row.DataItem, "Production"), String) = "" Then olblProduction.Visible = False Else olblProduction.Text = DataBinder.Eval(e.Row.DataItem, "Production") End If If CType(DataBinder.Eval(e.Row.DataItem, "System Downtime"), String) = "" Then olblSystemDowntime.Visible = False Else olblSystemDowntime.Text = DataBinder.Eval(e.Row.DataItem, "System Downtime") End If If CType(DataBinder.Eval(e.Row.DataItem, "Grand Total"), String) = "" Then olblGrandTotal.Visible = False Else olblGrandTotal.Text = DataBinder.Eval(e.Row.DataItem, "Grand Total") End If End If Catch ex As Exception General.LogException(ex) End Try End Sub </code></pre> <p>And if you want to hide entire column in grid please follow below step</p> <p>1) Create View state property on page for every column</p> <pre><code> Property RoleId() As boolen Get If IsNothing(Me.ViewState("RoleId")) Then Me.ViewState("RoleId") = false Return CType(Me.ViewState("RoleId"), Boolean) End Get Set(ByVal value As Boolean) Me.ViewState("RoleId") = value End Set End Property </code></pre> <p>2) Loop throw Data-set for every column for each row and check value exist or not and set this property ,finally you have property with value true or false and you can find which column need to display in grid.</p> <p>3)then you can easily hide column of grid.</p> <pre><code>if Me.RoleId= True then 'Write code to Display else 'Write code to Hide end if </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload