Click here to Skip to main content
15,886,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Good afternoon,

I'm sorry if the question is not formed well, but I didn't know how to describe the problem.

I'm retrieving data from SQL Server, and assign the values to text boxes in the Page_Load(..),
and in the button_click(..) I update the data and send them to the server to be updated,
but I always get the old values, even when I put some breakpoints to check if the problem from the code or in the Stored Procedure, I got the old values in the breakpoints values.

I'm not sure what did I do wrong

What I have tried:

C#
protected void Page_Load(object sender, EventArgs e)
    {
        _select = new Select();
        string _footerText = _select._GetFooterInfo();
        Dictionary<string, string> _headerItems = _select._GetHeaderInfo();
        
        txtAbout.Text = _headerItems["Header_About"];
}


C#
<pre>rotected void btnFooter_Click(object sender, EventArgs e)
    {
        Dictionary<string, string> _headerAndFooterInfo = new Dictionary<string, string>();
        _headerAndFooterInfo.Add("Header_About", txtAbout.Text);
.
.
.
        _update = new Update();
        _update._UpdateHeaderAndFooter(_headerAndFooterInfo);
Posted
Updated 19-Jan-21 7:42am
Comments
[no name] 19-Jan-21 10:21am    
Your "middle-man" dictionaries are a mystery as to what the point is. On the surface, it just looks like you're shuffling the same string between them and the text box (no "database" in sight).
Chander Parkash Mourya 19-Jan-21 12:03pm    
After update have you checked the value in database (value is update or not).
Share your code where you are assigning the value to the dictionary "_headerItems"

1 solution

The problem is in your Page_Load - you need to check the IsPostBack property[^] e.g. (untested)
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        _select = new Select();
        string _footerText = _select._GetFooterInfo();
        Dictionary<string, string> _headerItems = _select._GetHeaderInfo();
        
        txtAbout.Text = _headerItems["Header_About"];
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900