Solved

Insert Server Variable into GridView upon editing.

Posted on 2010-11-08
9
591 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 19

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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now