TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sheikh parvaz
NA
199
108.6k
Taking UserId from membership and storing in a table
Nov 13 2012 11:57 AM
namespace Supportticketsystem.Admins
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TicketConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void btnSend_Click(object sender, EventArgs e)
{
Session["UserLoginName"] = User.Identity.Name;
string ticketstatus = "Pending";
string userid = Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString();
SqlCommand cmd = new SqlCommand("Insert into Ticket(Type,Department,Category,Title,Detail,CreatedBy,CreateDate,UserId,CurrentStatus,CurrentStatusDate,LastUpdatedDate,LastUpdatedBy,RoomNo,Availabilty) values('" + ddlType.Text + "','" + ddlDepartment.Text + "','" + ddlCategory.Text + "','" + txtSubject.Text + "','" + txtMessage.Text + "','" + txtName.Text + "','" + userid + "','" + ticketstatus + "','" + DateTime.Now + "','" + Session["UserLoginName"] + "','" + DateTime.Now + "','" + txtRoom+ "','" + ddlAvailability.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Label4.Visible = true;
Label4.Text = "Data inserted successfully";
}
}
}
The above code is running good but "
string userid = Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString();
" line is showing error. It says "
string userid = Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString();"
k
indly help me out.
In above example I want to store information from textboxs, dropdownlists etc and also need UserId and UserName. Which I am trying from membership. Show the correct form of doing this pls. Also suggest if there is a better way.
Reply
Answers (
0
)
How to create Photo Album in asp.net like Facebook
How to send mail in asp.net mvc 3