<asp:datagrid id="dgContactHistory" runat="server" BorderColor="#999999" BorderWidth="1px" EnableViewState="True" ShowHeader="True" ShowFooter="True" AutoGenerateColumns="False" AllowSorting="True" OnEditCommand="dgContactHistory_EditCommand" OnCancelCommand="dgContactHistory_CancelCommand" OnDeleteCommand="dgContactHistory_DeleteCommand" OnItemCommand="AddContactHistory" OnUpdateCommand="dgContactHistory_UpdateCommand" DataKeyField="ContactHistoryID"> <Columns> <asp:TemplateColumn HeaderText="ContactDate" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label id="lblContactDate" runat="server"> <%# String.Format("{0:dd/MM/yy}",DataBinder.Eval(Container.DataItem, "ContactDate")) %> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="txtContactDate" runat="server" Columns="6" /> </FooterTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="TrustRep" > <ItemTemplate> <asp:Label id="lblTrustRep" runat="server"> <%# DataBinder.Eval(Container.DataItem, "TrustRepID") %> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:dropdownlist id="cboTrustReps" autopostback="false" datavaluefield="Value" datatextfield="Text" runat="server" Width="80px"></asp:dropdownlist> </FooterTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Campaign"> <ItemTemplate> <asp:Label id="lblCampaign" runat="server"> <%# DataBinder.Eval(Container.DataItem, "PhoneOpID") %> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:dropdownlist id="cboCampaigns" autopostback="false" datavaluefield="Value" datatextfield="Text" runat="server" Width="140px"></asp:dropdownlist> </FooterTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="ContactType" > <ItemTemplate> <asp:Label id="lblContactType" runat="server"> <%# DataBinder.Eval(Container.DataItem, "ContactTypeID") %> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:dropdownlist id="cboContactTypes" autopostback="false" datavaluefield="Value" datatextfield="Text" runat="server" Width="80px"/> </FooterTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="ConversationDetails"> <ItemTemplate> <asp:Label id="lblContactHistory" runat="server"> <%# DataBinder.Eval(Container.DataItem, "ConversationDetails") %> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="txtAddConversationDetails" runat="server" TextMode="MultiLine" Columns="45" /> </FooterTemplate> <EditItemTemplate> <asp:TextBox Columns="45" id="txtEditContactHistory" runat="server" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container.DataItem, "ConversationDetails") %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Removal" FooterStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:CheckBox id="chkRequestedRemoval" runat="server" Checked=<%# DataBinder.Eval(Container.DataItem, "RequestedRemoval") %>></asp:CheckBox> </ItemTemplate> <FooterTemplate> <asp:CheckBox runat="server" id="chkAddRequestedRemoval"/> </FooterTemplate> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit" > </asp:EditCommandColumn> <asp:TemplateColumn> <ItemTemplate> <asp:LinkButton runat="Server" Text="Delete" resourcekey="cmdDelete" CommandName="Delete" ID="Linkbutton2" /> </ItemTemplate> <FooterTemplate> <asp:LinkButton Text="Add" Runat="Server" resourcekey="cmdAdd" CommandName="doAdd" ID="Linkbutton1" /> </FooterTemplate> </asp:TemplateColumn> </Columns> </asp:datagrid>
Hi,
I have created an editable datagrid, which allows me to edit and delete using the asp:EditCommandColumn control. I have also inserted an Add functiontionality which sits in the footer at the bottom of each corresponding column (two text boxes, 3 dropdownlists, and an Add linkbutton) and everything works perfectly... except for 2 localization problems:
1. The column headers are not localized (I am using HeaderText="myColumn" in the ascx and myColumn.Header in the Rex file, which works well for me in other simple datagrids I have). I have tried to take out the asp:EditCommandColumn to see if it solves the problem but it didnt. My guess is that it might have something to do with having 3 types of templates (ItemTemplate, FooterTemplate and EditItemTempalte) within one asp:TemplateColumn, but I might be wrong.
2. I can't work out how to localize the "Edit", "Cancel" and "Update" buttons of the asp:EditCommandColumn. I have tried to put in a resourcekey="buttonName" as a property of the asp:EditCommandColumn, but it crashes with a complaint that resourcekey is not a known property. The other link buttons (Add and Delete) are localized ok with resourcekey.
Would appreciate help. I am enclosing the datagrid code:
| | |
|
|