Click to See Complete Forum and Search --> : load datagrid in edit mode?


RoniR
08-07-2007, 02:37 AM
hey guys i created a datagrid that has all the features (add,edit,cancel,save and search)
now when i am in edit mode i go to open a new page in order to search from items inside a dropdownlist and when i close this page i should populate the dropdownlist in the edititemtemplate with the search results..no problem there if i can load my datagrid when i come back from the seach page directly in edit mode. I did that and it worked when the dropdownlist was or when i searched in the footer since it reloaded my datagrid...What i need is when i open my page i want to c the datagrid in edit mode on the index i already selected.Hope i was clear. Thanks a lot

RoniR
08-07-2007, 04:06 AM
i actually solved it but i am not really convinced.What i really wanted is when i was in the edit mode and i clicked search and goit the search results i wanted to relod the page(reload the dropdownlist in my row with the new values) and keep my grid in edit mode.What i did is on from_load added a condition ... ComingFromEditSearch and called the dg_edit event
what freaked me out is that i had to declare a variable as System.Web.UI.WebControls.DataGridCommandEventArgs

since the "e" on from load is of type System.EventArgs

.
.' form_load
.
If ComingFromClientESearch Then
Dim X As System.Web.UI.WebControls.DataGridCommandEventArgs
dg_Edit(sender, X)
Else
DataBindGrid()
End If



Sub dg_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dg.EditCommand
Try
If ComingFromClientESearch Then
dg.EditItemIndex = EditSearchKey
Else
EditSearchKey = CInt(e.Item.ItemIndex)
dg.EditItemIndex = CInt(e.Item.ItemIndex)
End If

dg.ShowFooter = False
ComingFromEdit = True
DataBindGrid()
LoadCalendar()
Catch ex As Exception
lblMsg.Visible = True
lblMsg.Text = ex.Message
End Try

End Sub

is this logical?????? !!!!!
i mean it worked so far..
would welcome some comments