Fidelio,
I am not sure what the C# equivelant is for that line of code, play around with it and im sure that you will figure it out. Also your post was very vague in that you didn't specifiy if you were auto generating columns, buidling the datagrid on the fly, etc.
I use the above code in conjuntion with a Datagrid whos AutoGenerateColumns value is false then I have a Datagrid <columns></columns> collection. Inside of those columns i have something like this:
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton CommandName="Edit" Text="Edit" CausesValidation="false" runat="server" ID="Linkbutton1" />
<asp:LinkButton CommandName="Delete" CausesValidation="False" Text="Delete" runat="server" ID="lbDelete" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton CommandName="Cancel" CausesValidation="False" Text="Cancel" runat="server" />
<asp:LinkButton CommandName="Update" CausesValidation="True" Text="Update" runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
The 2 link buttons in the EditItemTemplate are hidden until the datagrid 'Edit' Command is called the first 2 link buttons appear as the first cell in every row and are visible when the Databind() method is called on the datagrid and if you look, i have named that link button so my code would look like this:
lb = CType(e.Item.Cells(0).FindControl("lbDelete"), LinkButton)
As far as your question about why do I use cells, that is how you manipulate controls or text inside of a datagrid, you have to select the cell and then the control you want to work with (or the text in the cell if there is no control). As far as the why for this? Ask Microsoft. Hope this helps.
"The one language all programmers understand is profanity."
|