Solved

Insert Server Variable into GridView upon editing.

Posted on 2010-11-08
9
597 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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