a gridview has a linkbutton (delete) between ItemTemplates only (no EditItemTemplate). There is nothing in code-behind about that linkbutton. There is also a commandfield.
In normal mode, the delete and the edit button are of course visible. When i click on the edit button, i still see the delete button for that row beside the update and the cancel button. How come? I would rather expect not to see the delete button in edit
mode.
a gridview has a linkbutton (delete) between ItemTemplates only (no EditItemTemplate). There is nothing in code-behind about that linkbutton. There is also a commandfield.
If I understand your problem statement, the you created a template column but only included the ItemTemplate. There's no EditItemTemplate. In this situation, the ItemTempate is always displayed. This allows you to control what fields within the row are
editable.
One solution is adding an empty EditItemTemplate or adding an EditItemTemplate with an empty label.
Well, you finally gave me the explanation. it took a while but we got there:
the ItemTemplate is always displayed in that case.
It took a while because of the "Cargo Cult Programming" style. It's unusual to create separate command button columns. A typical GridView design has one command button column where the buttons are dynamically displayed. Anyway, that's the default behavior.
Member
3 Points
48 Posts
How can a linkbutton between ItemTemplate be visible in edit mode?
Nov 25, 2020 09:36 AM|raffarin|LINK
Hi
I try to understand this situation:
a gridview has a linkbutton (delete) between ItemTemplates only (no EditItemTemplate). There is nothing in code-behind about that linkbutton. There is also a commandfield.
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="ann" runat="server" CausesValidation="false" OnClientClick="return confirm('OK?');" CommandName="Delete" >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" CausesValidation="false"/>
In normal mode, the delete and the edit button are of course visible. When i click on the edit button, i still see the delete button for that row beside the update and the cancel button. How come? I would rather expect not to see the delete button in edit mode.
Thanks
Raf
All-Star
52201 Points
23274 Posts
Re: How can a linkbutton between ItemTemplate be visible in edit mode?
Nov 25, 2020 01:25 PM|mgebhard|LINK
If I understand your problem statement, the you created a template column but only included the ItemTemplate. There's no EditItemTemplate. In this situation, the ItemTempate is always displayed. This allows you to control what fields within the row are editable.
One solution is adding an empty EditItemTemplate or adding an EditItemTemplate with an empty label.
Member
3 Points
48 Posts
Re: How can a linkbutton between ItemTemplate be visible in edit mode?
Nov 25, 2020 02:28 PM|raffarin|LINK
Well, you finally gave me the explanation. it took a while but we got there: the ItemTemplate is always displayed in that case.
And your solution works too. No need for code-behind.
Sometimes you have to persevere ...
Thanks
All-Star
52201 Points
23274 Posts
Re: How can a linkbutton between ItemTemplate be visible in edit mode?
Nov 25, 2020 03:35 PM|mgebhard|LINK
It took a while because of the "Cargo Cult Programming" style. It's unusual to create separate command button columns. A typical GridView design has one command button column where the buttons are dynamically displayed. Anyway, that's the default behavior.
Member
3 Points
48 Posts
Re: How can a linkbutton between ItemTemplate be visible in edit mode?
Nov 26, 2020 08:50 AM|raffarin|LINK
I understand. Not always easy to admit that we were wrong