ProfK
ProfK

Reputation: 51063

DataGrid Edit Problem

I have a DataGrid, with an ItemTemplate that has an image and label. In the EditItemTemplate the label is replaced by a textbox. My problem is that the edit template only shows when I click the Edit button the second time. What gives?

Upvotes: 0

Views: 781

Answers (2)

Raelshark
Raelshark

Reputation: 3065

Make sure you're re-binding the DataGrid after setting the EditItemIndex property.

Edit: Agreed with Massa. Best practice is to move your databinding into a separate method and call it first on the first page load, and again after setting EditItemIndex.

Upvotes: 0

EndangeredMassa
EndangeredMassa

Reputation: 17528

Make sure you check for Page.IsPostback before binding your datagrid. It may be the case that you are binding during every page load.

If Not Page.IsPostBack() Then
    DoDataBinding()
End If

Upvotes: 1

Related Questions