Solved

Insert Server Variable into GridView upon editing.

Posted on 2010-11-08
9
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 36

Expert Comment

by:Miguel Oz
ID: 34088533
This is your required server variable:
Text='<%# Bind([this.Page.User.Identity.Name]) %>'
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 36

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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