I have a templated CommandField I am trying to get formatted when the grid goes into Edit mode. I have an ItemStyle defined setting the width of the column which works great before it goes into Edit mode but this doesn't affect the column width when it
is in Edit mode. I must be missing something, but haven't been able to figure out how to style my grid in Edit.
rmathews@lig...
Member
3 Points
9 Posts
Formatting Gridview EditItemTemplate
Jan 20, 2013 06:34 PM|LINK
I have a templated CommandField I am trying to get formatted when the grid goes into Edit mode. I have an ItemStyle defined setting the width of the column which works great before it goes into Edit mode but this doesn't affect the column width when it is in Edit mode. I must be missing something, but haven't been able to figure out how to style my grid in Edit.
Any ideas?
Markup:
<asp:GridView ID="gvAuthPickups" runat="server" AutoGenerateColumns="False" DataSourceID="dsAuthPickups" DataKeyNames="ID" CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:TemplateField ShowHeader="False"> <EditItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" ForeColor="White"></asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" ForeColor="White"></asp:LinkButton> </EditItemTemplate> <ControlStyle CssClass="gvCommands" /> <ItemStyle Width="125px" /> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('Are you sure yuou want to delete this authorization?')" Text="DEL"></asp:LinkButton> </ItemTemplate> <ItemStyle ForeColor="Red" Width="125px" /> </asp:TemplateField> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="True" Visible="False" /> <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" /> <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" /> <asp:TemplateField HeaderText="Phonetype" SortExpression="Phonetype"> <EditItemTemplate> <asp:DropDownList ID="ddlPhoneTypeEdit" runat="server" SelectedValue='<%# Bind("Phonetype") %>' Width="75px"> <asp:ListItem Value="-1" Selected="True">-- Select --</asp:ListItem> <asp:ListItem Value="C">Cell</asp:ListItem> <asp:ListItem Value="H">Home Phone</asp:ListItem> <asp:ListItem Value="W">Work Phone</asp:ListItem> <asp:ListItem Value="O">Other</asp:ListItem> </asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:DropDownList ID="ddlPhoneType" runat="server" SelectedValue='<%# Bind("Phonetype") %>' Width="75px"> <asp:ListItem Value="-1" Selected="True">-- Select --</asp:ListItem> <asp:ListItem Value="C">Cell</asp:ListItem> <asp:ListItem Value="H">Home Phone</asp:ListItem> <asp:ListItem Value="W">Work Phone</asp:ListItem> <asp:ListItem Value="O">Other</asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Relationship" HeaderText="Relationship" SortExpression="Relationship" /> <asp:BoundField DataField="PickupOK" HeaderText="PickupOK" SortExpression="PickupOK" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Size="8pt" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView>Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Formatting Gridview EditItemTemplate
Jan 22, 2013 02:19 AM|LINK
Hi,
You can just use EditItemStyle instead.