Last post Dec 22, 2017 06:27 AM by email@example.com
Dec 21, 2017 06:15 AM|MuhammadNaveedHaroon|LINK
protected void SaveChangesBtn_Click(object sender, EventArgs e)
SqlCommand comm = new SqlCommand("update Users set EmailAddress = '" + EmailAddressTextBox.Text + "',FName = '" + FirstNameTextBox.Text + "',LName = '" + LastNameTextBox.Text + "',ContactNumber='" + ContactNumberTextBox.Text + "',[Address]='" + AddressTextBox.Text + "',PostalCode='" + PostalCodeTextBox.Text + "' where UserID = " + SelectedID, conn);
selectedID become zero every time i click this button, where as the data is passed by other method and in debug mode i checked that the value is passed in this variable. But when i click the selectedID become 0 automatically. How to resolve this?
Muhammad Naveed Haroon
Dec 21, 2017 05:05 PM|paindaasp|LINK
Where and when are you setting the value of SelectedID?
Perhaps you need to save it in ViewState, a Session variable, or some other method and use that when you do your update.
Dec 22, 2017 02:53 AM|Cathy Zou|LINK
Hi Muhammad Naveed Haroon,
From your brief description and a short code, it is difficult for us to provide you with a solution that meets your requirements.
We need to know the specifics about your problem
You could post some code about your problem so that we could reproduce your problem and find solution for you.
Dec 22, 2017 06:27 AMfirstname.lastname@example.org|LINK
where is the value for variable SelectedID. for int the default value is 0. You are not assigning any value to the variable. Because of that it is passing as 0.