Click twice for dataload into listbox

I have a gridview which when I click the gridview edit button it loads some values into a listbox.

My problem is that I have to click the edit button twice for this to happen. Is there a reason for this.

I am using c# and asp.net
Mr_ShawAsked:
Who is Participating?
 
Obadiah ChristopherConnect With a Mentor Commented:
Make sure u have checked for the IsPostBack Condition in page load where you might have written code to bind the grid.
0
 
Mr_ShawAuthor Commented:
I am not sure what you mean

page_load and the code benhind the grid and two seperate sections
0
 
Obadiah ChristopherCommented:
Where have u written code to bind the grid? in  Page load
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Mr_ShawAuthor Commented:
I have tried running my code both inside  and outside of

if (Page.IsPostBack)
        {
}
0
 
Mr_ShawAuthor Commented:
Everything seems to be acting on the previous click.

for example to value selected in the 1st click was one
the value selected in the 2nd click was two.

When I click for the second time the 1st clicks values is processed. ahhhhhhhh
0
 
srikanthreddyn143Connect With a Mentor Commented:
Move the focus out of gridview in click event
0
 
Mr_ShawAuthor Commented:
what do you mean by move the focus.... do you think you could give me an example?
0
 
srikanthreddyn143Commented:
When Edit button is clicked, Make the focus move to any other control like txtboxx1.focus()
0
 
Mr_ShawAuthor Commented:
I'm really sorry to have to say this... but changing the focus does not help.

My code is always one click behind what I am actually doing,

Everything seems to be acting on the previous click.

for example to value selected in the 1st click was one
the value selected in the 2nd click was two.

When I click for the second time the 1st clicks values is processed. ahhhhhhhh
0
 
Mr_ShawAuthor Commented:
thanks for the help....

It ended up being the way I ordered my code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.