Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid have to hit edit button 2X - why

Status
Not open for further replies.

gcole

Programmer
Aug 2, 2000
390
US
I have a datagrid with the following event:
public void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
}

When I debug and hit the Edit button, it runs through this code until the selected record is found. Then I have to hit the same button again to turn the selected column into a text box. Does anyone know what is causing this?
 
I am setting these buttons visible properties in code. They are also next to each other in a table cell. but seperating them doesn't change anything. Anyone have an idea?
 
Sounds like your page is reloading, before the code is executed. Then when you run it a second time, the code changes that took effect after are now applied on the next reload.

 
I found the problem. The text box in the tab order before the button was posting back to the server. It wasn't finished when the button was clicked. I disabled the post back (as I don't need it) and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top