Comparing Page.User.Identity.Name to value in sql Table
- by Peggy Fusselman
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!