Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

At first I tell you what I will do:

 

1. Load data from DB

2. Fill System.Web.UI.WebControls.TextBox with data from DB

3. Than the user can change some data in the System.Web.UI.WebControls.TextBox

 

and now how I can compare what the user change?

 

should I add a new Item to Context.Items and compare it after changes?

 

any idea?

 

 

regards,

 

 

gicio

Posted
When you load the data from the DB, store it in 2 textboxes (or two places, they don't both have to be textboxes). Then when the user changes one, compare the text to the original (the other unchanged textbox). It should be easy enough to compare to strings.
Posted
Is "Context" the textbox or what? It really doesn't matter where the data is stored, but what I was recommending was that you store it in two textboxes. One that the user can edit "tbUser.Text", and the other being the original "tbOriginal.Text". Maybe we are mis-understanding each other. If you are not sure what I am talking about, then please elaborate on your use of Context.Items (possibly with some code).
  • *Gurus*
Posted
Context.Items is not what you're looking for. Once the user posts the page back with any changes the database should be requeried and comparisons should be made from there. If you don't do it in such a manner your application is going to suffer huge concurrency issues.
Posted

		private void FillControlsWithData()
	{
		UsersDB currentUsersDB = new UsersDB();
		
		SqlDataReader dr = currentUsersDB.GetSingleUser(Context.User.Identity.Name);

		// Read first row from database
		dr.Read();

		Context.Items.Add("UserFirstName",(String) dr["FirstName"]);

		
		dr.Close();	

		m_txtFirstName.Text = Context.Items["UserFirstName"].ToString()
	}


	private void m_cmdChangeData_Click(object sender, System.EventArgs e)
	{
		if( !(m_txtFirstName.Text == Context.Items["UserFirstName"].ToString()) )
		{
			//make something stuff here!!!!
		}
	}

 

 

 

In the if( !(m_txtFirstName.Text == Context.Items["UserFirstName"].ToString()) ) I get an error:

 

 

 

Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


Line 169:			{
Line 170:				if( !(m_txtFirstName.Text == Context.Items["UserFirstName"].ToString()) )
Line 171:				{
Line 172:					//make something stuff here!!!!


Source File: c:\inetpub\wwwroot\immo\desktopmodules\usereditdata.ascx.cs    Line: 170 

Stack Trace: 


[NullReferenceException: Object reference not set to an instance of an object.]
  OcImmobilienPortal.UserEditData.m_cmdChangeData_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\immo\desktopmodules\usereditdata.ascx.cs:170
  System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
  System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  System.Web.UI.Page.ProcessRequestMain()

 

any idea what the problem is?

 

 

regards,

 

 

gicio

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...