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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set girdview.EditIndex to last row 1

Status
Not open for further replies.

swetab

Programmer
May 6, 2003
49
US
Hi,

On button click I set the editindex, it doesn't apply when I click the button again it shows the row set in the edit mode why?

I have grid view and a button "Add" control on aspx page and when I new is clicked I need to add the set the editindex of the grid to last column:
this is what I am doing

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

Dim oData As New DataTable
Dim oRow As DataRow
oData = Cache("tbl")

oRow = oData.Rows.Add
grdTimes.DataSource = oData
grdTimes.DataBind()
Cache("tbl") = oData
grdTimes.EditIndex = oData.Rows.Count

End Sub

When I click on the Add first time it doesn't display in the edit mode.
When I click on the Add the second time it opens in the edit mode what is the problem?

Thanks.
 
try setting the edit index before binding the grid.

I also would not use cache for this. cache is global temporary storage that can be cleared at any point without notice. I would recommend either viewstate or session.
being global it will effect all users, not just the current user.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason you are absolutely correct with set the edit index before binding the grid.

Thanks for looking into my thread and responding so quickly I appreciate for looking deeper into my code and suggesting valuable technique.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top