locked
listview need to update db before running code RRS feed

  • Question

  • User-1844117248 posted

    hi 

    i need to get my listview there are made on a LinqDataSource to update the db before it running my code i have made in my update botton.


    how do i force the update to happen ind c# ? 

    my code in my update botton looks like this 


     protected void UpdateButton_Click(object sender, EventArgs e)
        {
            
            int id = ListView1.EditIndex + 2;
           
            DataClassesDataContext db = new DataClassesDataContext();
            
            
            var query = from a in db.GameTables
                        where a.Game_number == id
                        select new
                        {
                            a.HoldA,
                            a.HoldB,
                            a.ResualtHoldA,
                            a.ResualtHoldB,
                            a.Group,
                        };
            //kamp er nu en liste der qaltid kun indholder et element fordi vi bruger id i vores select
            var kamp = query.ToList();
            if (kamp[0].ResualtHoldA > kamp[0].ResualtHoldB)
            {
                //et eller andet holdA vinder
               
               
            }
            else if (kamp[0].ResualtHoldB > kamp[0].ResualtHoldA)
            {
                //et eller andet holdB vinder
            }
            else if (kamp[0].ResualtHoldB == kamp[0].ResualtHoldA)
            {
                //uafgjort
            }
            else
            {
                //Der er sket noget uforudset
            }
            
        }



     protected void UpdateButton_Click(object sender, EventArgs e)
        {
            
    
            int id = ListView1.EditIndex + 2;
           
            DataClassesDataContext db = new DataClassesDataContext();
            
            
            var query = from a in db.GameTables
                        where a.Game_number == id
                        select new
                        {
                            a.HoldA,
                            a.HoldB,
                            a.ResualtHoldA,
                            a.ResualtHoldB,
                            a.Group,
                        };
    
            //kamp er nu en liste der qaltid kun indholder et element fordi vi bruger id i vores select
            var kamp = query.ToList();
    
            if (kamp[0].ResualtHoldA > kamp[0].ResualtHoldB)
            {
                //et eller andet holdA vinder
               
               
            }
            else if (kamp[0].ResualtHoldB > kamp[0].ResualtHoldA)
            {
                //et eller andet holdB vinder
            }
            else if (kamp[0].ResualtHoldB == kamp[0].ResualtHoldA)
            {
                //uafgjort
            }
            else
            {
                //Der er sket noget uforudset
            }
            
        }



    is there any one there can help?



    Tuesday, December 21, 2010 5:43 PM

Answers

  • User1716267170 posted

    i need to get my listview there are made on a LinqDataSource to update the db before it running my code i have made in my update botton.

     

    When the button is clicked, the button click event will be fired immediately. There's no other event for you to add your own extra code. Thus, I suggest you to call your method before the code executes in button click event like this:

  • protected void UpdateButton_Click(object sender, EventArgs e)   
  • {
        // Call your method/code here.
  •    int id = ListView1.EditIndex + 2;     
       ....
  • }

    Thanks.

  • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 29, 2010 3:59 AM

All replies

  • User-1844117248 posted

    here is the code fo my botton


    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                            Text="Update" OnClick="UpdateButton_Click" />




    Wednesday, December 22, 2010 1:54 PM
  • User1716267170 posted

    i need to get my listview there are made on a LinqDataSource to update the db before it running my code i have made in my update botton.

     

    When the button is clicked, the button click event will be fired immediately. There's no other event for you to add your own extra code. Thus, I suggest you to call your method before the code executes in button click event like this:

  • protected void UpdateButton_Click(object sender, EventArgs e)   
  • {
        // Call your method/code here.
  •    int id = ListView1.EditIndex + 2;     
       ....
  • }

    Thanks.

  • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 29, 2010 3:59 AM