Last post Mar 10, 2017 09:28 AM by Zhi Lv - MSFT
Mar 09, 2017 09:18 AM|robby32|LINK
I assign values to a dataset and from that I assign the appropriate controls in the markup the values . For example the label is meant to get a new value , but it sems to keep showing the previous value that was assigned to the dataset . If i duebtg li
see he new vaues but when the page is rendered the values are incorrect .
Its as if the values are not being assigned to the html control. One control is a asp:label and in the serverside code I assign it simply by
labelid .text = "new value"
but it is not assigned . This is happening to a number of controls on the page.
Is there something that would cause this ?
Mar 09, 2017 09:31 AM|kaushalparik27|LINK
it sems to keep showing the previous value that was assigned to the dataset
Are you using UpdatePanel? Can you provide some more detail on your code?
If you are using UpdatePanel and you are setting original/previous values in say page_load and then on any event like Button click, you are assigning new value then make sure both buttons and label is in UpdatePanel.
Mar 10, 2017 09:28 AM|Zhi Lv - MSFT|LINK
How do you set the new value to your label? By a button click?
Could you provide your code that I can help you solve this problem ?
I have create a simple demo that change the label text by a button click, hope it can help
In behind code:
protected void Page_Load(object sender, EventArgs e)
DataTable dt = new DataTable();
for(var i = 0; i < 5; i++)
GridView1.DataSource = dt;
protected void button1_Click(object sender, EventArgs e)
Label label =(Label)GridView1.Rows.FindControl("label1");
label.Text = "new text";
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<asp:Label ID="label1" runat="server" Text='<%# Eval("col1") %>' />
<asp:Button runat="server" ID="button1" OnClick="button1_Click" />
And the result is: