Solved

Insert Server Variable into GridView upon editing.

Posted on 2010-11-08
9
594 Views
Last Modified: 2012-05-10
In my GridView I'd like to put the equivilant of this:  Request.ServerVariables("AUTH_USER") into the column called "ModifiedBy".

The idea is when someone edits a row their logged in user name is put into the "ModifiedBy" column.
0
Comment
Question by:megnin
  • 6
  • 2
9 Comments
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 34088271
I think you want to look into BIND and EVAL:

http://msdn.microsoft.com/en-us/library/ms178366.aspx

0
 
LVL 1

Author Comment

by:megnin
ID: 34088363
What I want is to grab the Server Variable for the logged in user as a parameter and plug it into the GridView.

The ModifiedBy field is currently a BoundField, but I could change it to a TemplateField.  I just don't know how to get the Server Variable for the logged in user value into the GridView.  I expect it will have to be done in the VB code behind, but I'm not sure if it can't be done in the GridView markup some how.

Text='<%# Bind([Server Variable for logged in user]) %>'  ??
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 34088533
This is your required server variable:
Text='<%# Bind([this.Page.User.Identity.Name]) %>'
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 500 total points
ID: 34088557
This is your required server variable:   (Page.User.Identity.Name)
Text='<%# Bind([Page.User.Identity.Name]) %>'

or   (Request.LogonUserIdentity.Name)
Text='<%# Bind([Request.LogonUserIdentity.Name]) %>'
0
 
LVL 1

Author Comment

by:megnin
ID: 34092600
With square brackets, round brackets or no brackets?
0
 
LVL 1

Author Comment

by:megnin
ID: 34092622
Text='<%# Bind([Page.User.Identity.Name]) %>'
Text='<%# Bind([Request.LogonUserIdentity.Name]) %>'
Text='<%# Bind(Page.User.Identity.Name) %>'
Text='<%# Bind(Request.LogonUserIdentity.Name) %>'

All those give me a Parse Error:  A call to Bind was not well formatted.
0
 
LVL 1

Accepted Solution

by:
megnin earned 0 total points
ID: 34232469
Well, I ended up setting this, Request.ServerVariables("AUTH_USER"), to a variable in the code behind and using the code below to handle when a row is updated.
Protected Sub GridView1_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles GridView1.RowUpdated
        If GridView1.EditIndex <> -1 Then
            Dim iReqID As Integer = CType(GridView1.DataKeys(GridView1.EditIndex).Value, Integer)        'CInt(GridView1.DataKeys(GridView1.EditIndex).Value)
            Dim iModifiedBy As String = iUserName
            Call SendModifiedByToRequisition(iModifiedBy, iReqID)
        End If
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:megnin
ID: 34232533
I ended up going a different route, but mas_oz2003's help lead me down the right path.  I used a different method, but gave mas_oz2003 the points for the aid.
0
 
LVL 1

Author Closing Comment

by:megnin
ID: 34272760
Thanks for the help.  It lead me in the right direction.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question