Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Updating datalist

Posted on 2013-06-24
4
Medium Priority
?
463 Views
Last Modified: 2013-06-25
Hi,

I am updating a database from the data from datalist control. update works fine. I call call a sub procedure after the update to display grand total in label field out side the datalist. It also works but I have click the button twice. in a single click update works and displaying total inside lblTotal.Text works in a single click of the button.

 protected void btnUpdate_Click(object sender, EventArgs e)
    {

       foreach (DataListItem dli in DataList1.Items) 
            if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem)
            {
                update.ExecuteNonQuery();

                lblTotal.Text = total.ToString();

            }
            CalculateGTotal();
        }
    }

Open in new window


Please help.

ayha
0
Comment
Question by:ayha1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 1000 total points
ID: 39271913
Is the button set to AutoPostBack="True"?

Is the label outside of the datalist in an update panel?

Either of these would probably fix it for you. I would try the AutoPostBack on the button first.
0
 
LVL 7

Author Comment

by:ayha1999
ID: 39271974
Button is outside of the datalist and user click to update.

Label is outside of the datalist and not in an update panel.
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39272518
Is the button set to AutoPostBack="True"?

The page is probably updating, but you are not seeing the update until the page refreshes. An update panel would allow partial page updates to see the label value change. Having the button set to AutoPostBack="True" forces the page to refresh.
0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 39274934
Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question