Comparing Page.User.Identity.Name to value in sql Table

Posted by Peggy Fusselman on Stack Overflow See other posts from Stack Overflow or by Peggy Fusselman
Published on 2012-09-02T14:56:22Z Indexed on 2012/09/02 15:38 UTC
Read the original article Hit count: 223

Filed under:
|
|
|

First, I am SO sorry if the answer is out there. I've looked and looked and feel this is such a simple thing that it should be obvious.

I'm wanting to make sure only the person who added an event can modify it. Simple!

I already have a datasource that has event_added_by as a data point. It is populating a FormView.

       SelectCommand="SELECT * FROM [tbl_events] WHERE ([event_ID] = @event_ID)"

And I have Page.User.Identity.Name.

How do I compare the two? I can't pull the value from the label in the FormView so I need to find another way.

    if (!IsPostBack)
    {
        string uname = Page.User.Identity.Name;
        string owner = ""// this is where I need to grab the value from dsEvents;

        if (uname != owner)
        {
            //Send them somewhere saying they're not allowed to be here
        }

    }

TIA for any help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET