I have this code now and it works partially.
button then I dont see the datagrid in edit mode. Although
the sender.ID is printer. Now when I press the second
time, then the datagrid is in edit mode. I dont understand
this. Basically the datagrid goes in edit mode when I
click the edit button twice. What can cause such a
>-----Original Message-----
>BTW: Isnt the sender the datagrid?
>
>
>>-----Original Message-----
>>Thanks for the reply Scott. Yes I am doing it this way.
>>When I use your code and press the edit button then I
get
>>the following error:
>>
>>System.InvalidCastException: Specified cast is not valid.
>>
>>What can I do here?
>>
>>Vishal
>>
>>
>>>-----Original Message-----
>>>Vishal, are you wiring up the EditCommand to the event
>>handler in your
>>>declarative syntax, like so?
>>>
>>><asp:DataGrid id="OutterDataGrid" ...>
>>> <Columns>
>>> ...
>>> <asp:TemplateColumn>
>>> <ItemTemplate>
>>> <asp:DataGrid id="InnerDataGrid"
>>OnEditCommand="dgNested_Edit"
>>>.... />
>>> </ItemTemplate>
>>> </asp:TemplateColumn>
>>> ...
>>> </Columns>
>>></asp:DataGrid>
>>>
>>>???
>>>
>>>Now, you won't be able to access dgNested directly from
>>the EditCommand
>>>event handler, but the sender parameter passed into the
>>event handler
>>>is, IIRC, the Edit button. Now, you can get to the
>>DataGrid like so
>>>(untested code follows):
>>>
>>>Sub dgNested_Edit(ByVal sender As Object, ByVal e As
>>>DataGridCommandEventArgs)
>>> Dim myInnerDG as DataGrid
>>> Dim myEditButton as Button = CType(sender, Button)
>>>
>>> myInnerDG = CType
>(myEditButton.Parent.Parent.Parent,
>>DataGrid)
>>>
>>> myInnerDG.EditItemIndex = ...
>>>end sub
>>>
>>>
>>>The Button's Parent is the TableCell it exists in.
It's
>>Parent is the
>>>DataGridItem. And the DataGridItem's parent is the
>>DataGrid. That's
>>>why we do .Parent.Parent.Parent. Hope this makes
>>sense! :-)
>>>
>>>
>>>--
>>>
>>> Scott Mitchell
>>> mitchell@4guysfromrolla.com
>>>
http://www.4GuysFromRolla.com >>>
>>>* When you think ASP.NET, think 4GuysFromRolla.com!
>>>.
>>>
>>.
>>
>.