I should be able to figure this out but for some reason I cannot figure out where to start.
I have a datagrid that shows a list of available dates. You can click on these dates and they will pull up a report for that date. I have three other reports that I want to do the same thing for. But I do not want the datagrid to show up if the individual logged in doesn't have access to those reports. Here is the code I have. Don't laugh too hard, I know it is a mess.
The three other reports will have a datagrid identical to the one above accept the hyperlink will point to a different page. For these grids to show the following criteria needs to be met
session("Manager") needs to be "Yes"
Needs to return atleast one row.
I have a datagrid that shows a list of available dates. You can click on these dates and they will pull up a report for that date. I have three other reports that I want to do the same thing for. But I do not want the datagrid to show up if the individual logged in doesn't have access to those reports. Here is the code I have. Don't laugh too hard, I know it is a mess.
Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load(Sender As Object, E As EventArgs)
Dim ConnectionString As String = "server=NOPE ; database=DONOT ; User Id= NEED ; Password = THAT"
Dim CommandText2 As String = "SELECT * FROM [ResidualAvail] where status = 'global'"
Dim myConnection As New SqlConnection(ConnectionString)
Dim MyCommand2 As New SqlDataAdapter(CommandText2,myconnection)
Dim avail As DataSet
myConnection.Open
myCommand2 = New SqlDataAdapter(CommandText2,MyConnection)
avail = New DataSet()
myCommand2.Fill(avail,"[ResidualAvail]")
availGrid.DataSource = Avail.Tables("[ResidualAvail]")
availGrid.DataBind
myconnection.Close
End Sub
</script>
<strong><font color="#330066">Residuals reports are available for: </strong>
<p></p>
<asp:datagrid
id="AvailGrid" showheader="false"
runat="server" CellSpacing="1" CellPadding="3" BackColor="#efefef" ForeColor="Black"
EnableViewState="False" autoGenerateColumns="false">
<columns>
<asp:HyperLinkColumn
HeaderText="Month/Year"
DataTextField="Month"
DataTextFormatString="{0:MMMM, yyyy}"
DataNavigateUrlField="Month"
DataNavigateUrlFormatString="Residualstatement.aspx?id={0:'DatePart(YEAR,Month)='yyyy 'AND DatePart(MONTH,Month)='MM&'id2'=MMMM yyyy}"/>
</columns>
</asp:dataGrid>
The three other reports will have a datagrid identical to the one above accept the hyperlink will point to a different page. For these grids to show the following criteria needs to be met
session("Manager") needs to be "Yes"
Code:
SELECT AgentID FROM DivisionHistory WHERE ('" & Session("Number") & "' = AgentID)