Solved

Insert Server Variable into GridView upon editing.

Posted on 2010-11-08
9
596 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 36

Expert Comment

by:Miguel Oz
ID: 34088533
This is your required server variable:
Text='<%# Bind([this.Page.User.Identity.Name]) %>'
0
Industry Leaders: 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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