Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Granting a session access to parts in a gridview

Status
Not open for further replies.

nc297

Programmer
Apr 7, 2010
162
US
If you are in session(DMXXX) I want you to have access to the row with links of 230, 243, 247. This person is in district 230 and oversees offices 243 and 247 so when you come on this page I want the person to have links. I have a querystring with dist so this one would come over as dist="230"


Region A B C D
PHI 65234 89546 85423 85421
AREA 5489 4587 2456 4597
230 12 56 23 12
243 125 6 4 4
247 15 14 78 89

Would I put this in pageload?

If Session("Pos") = "DMXXX" Then

Dim sqlConnection1 As NewData.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("PendingClaimsConnectionString").ConnectionString)

Dim cmd As New SqlCommand
cmd.Connection = sqlConnection1
cmd.CommandText = "GetDistInfo"
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@officecode", Request.QueryString("officecode"))
cmd.Parameters.AddWithValue("@reportsto", Request.QueryString("reportsto"))
cmd.Connection.Open()
cmd.Connection.Close()


If e.Row.RowType = DataControlRowType.DataRow Then


'Checking specific position access by fieldoffice and Expception
'comparing the doc column value (which is called region on the gridview) to session FO
If DirectCast(e.Row.DataItem, DataRowView)("doc").ToString() = Session("FO").ToString() Or Session("PendingClaims") Then


'Checking ADXXX access to only show links for their area
ElseIf (Session("FO") = "H20" And Request.QueryString("area") = "01") Or _
(Session("FO") = "H21" And Request.QueryString("area") = "02") Or _
(Session("FO") = "H22" And Request.QueryString("area") = "03") Or _
(Session("FO") = "H23" And Request.QueryString("area") = "04") Or _
(Session("FO") = "H24" And Request.QueryString("area") = "05") Or _
(Session("FO") = "H25" And Request.QueryString("area") = "06") Then


e.Row.Cells(5).Enabled = True
e.Row.Cells(6).Enabled = True
e.Row.Cells(7).Enabled = True
e.Row.Cells(8).Enabled = True
e.Row.Cells(9).Enabled = True
e.Row.Cells(10).Enabled = True

How would I get the DMXXX? I hope this makes sense.
 
I am not sure what your question is.
The check for/of the session variable goes in the page_Load
The other code looks like it should be in your grid ItemDataBound event.
 
When a DMXXX goes to the page I want it to check to see if they are a DMXXX and if so apply links to their offices that they oversee/

So you are saying this code should go in the Page Load section:

If Session("Pos") = "DMXXX" Then

Dim sqlConnection1 As NewData.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("PendingClaimsConnectionString").ConnectionString)

Dim cmd As New SqlCommand
cmd.Connection = sqlConnection1
cmd.CommandText = "GetDistInfo"
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@officecode", Request.QueryString("officecode"))
cmd.Parameters.AddWithValue("@reportsto", Request.QueryString("reportsto"))
cmd.Connection.Open()
cmd.Connection.Close()
 
Okay thanks then I check for DMXXX here right? Where would I put the checking for that?

If e.Row.RowType = DataControlRowType.DataRow Then


'Checking specific position access by fieldoffice and Expception
'comparing the doc column value (which is called region on the gridview) to session FO
If DirectCast(e.Row.DataItem, DataRowView)("doc").ToString() = Session("FO").ToString() Or Session("PendingClaims") Then


'Checking ADXXX access to only show links for their area
ElseIf (Session("FO") = "H20" And Request.QueryString("area") = "01") Or _
(Session("FO") = "H21" And Request.QueryString("area") = "02") Or _
(Session("FO") = "H22" And Request.QueryString("area") = "03") Or _
(Session("FO") = "H23" And Request.QueryString("area") = "04") Or _
(Session("FO") = "H24" And Request.QueryString("area") = "05") Or _
(Session("FO") = "H25" And Request.QueryString("area") = "06") Then


e.Row.Cells(5).Enabled = True
e.Row.Cells(6).Enabled = True
e.Row.Cells(7).Enabled = True
e.Row.Cells(8).Enabled = True
e.Row.Cells(9).Enabled = True
e.Row.Cells(10).Enabled = True

 
Check that while the grid is binding, during the RowDataBound event
 
Perfect I will try it in the morning!
 
Still having problems with this but someone here is helping me with it. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top