eramgarden Posted March 15, 2004 Posted March 15, 2004 I'm following the example in this site: http://aspnet.4guysfromrolla.com/articles/071002-1.2.aspx It uses "BoundColumn" and "Edit/Update/Cancel" that goes with each row...Click on "Edit", and you'll get "Update/Cancel" buttons and the fields change to text fields for editing But I want to use "TemplateColumn" with "Edit/Update/cancel" button next to each row... However, when I have "TemplateColumn", and click on "Edit", i DO get the "update/cancel" buttons but the field DOES NOT change to a text field for me to change the text in it.. So, I cant use "TemplateColumn" with "Edit/Update/Cancel"?? Quote
Moderators Robby Posted March 15, 2004 Moderators Posted March 15, 2004 Does each field Allow Edit ? (ReadOnly = False) Quote Visit...Bassic Software
kahlua001 Posted March 15, 2004 Posted March 15, 2004 Also, do you have an <EditItemTemplate> in your template column Quote
eramgarden Posted March 15, 2004 Author Posted March 15, 2004 I tried to add <EditItemTemplate> but it didnt like it..got a redline under it saying cannot find the member <EditItemTemplate> ... This is what I have: ----- <asp:datagrid id="dgViewDetail" style="Z-INDEX: 101; LEFT: 230px; POSITION: absolute; TOP: 148px" runat="server" AutoGenerateColumns="False" Width="697px" Height="200px" OnEditCommand="Site_Edit"> <Columns > <asp:TemplateColumn > <ItemTemplate > <table border="0"> <tr> <td align="right"><b>Site Name:</b></td> <td><%# DataBinder.Eval(Container.DataItem, "cmp_name1") %></td> </tr> <tr> <td align="right"><b>Site Addr1:</b></td> <td><%# DataBinder.Eval(Container.DataItem, "cmp_addr1") %></td> </tr> </table> </ItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn> </Columns> </asp:datagrid> Quote
kahlua001 Posted March 15, 2004 Posted March 15, 2004 Can you post where you had the <EditItemTemplate> . When you enter edit mode, it looks for the Edit template for that datagrid item. Quote
eramgarden Posted March 15, 2004 Author Posted March 15, 2004 <asp:edititemtemplate><%# DataBinder.Eval(Container.DataItem, "cmp_name1") %></edititemtemplate></td> But then in design view, the grid has "error creating grid" msg Also Tried: <asp:TemplateColumn> <asp:edititemtemplate> <table border="0"> <tr> <td align="right"><b>Site Name:</b></td> <td><%# DataBinder.Eval(Container.DataItem, "cmp_name1") %></td> </tr> <tr> <td align="right"><b>Site Addr1:</b></td> <td><%# DataBinder.Eval(Container.DataItem, "cmp_addr1") %></td> </tr> </table> </edititemtemplate> </asp:TemplateColumn> Quote
kahlua001 Posted March 15, 2004 Posted March 15, 2004 I believe its.. <asp:TemplateColumn> <ItemTemplate> <%# Container.DataItem("Name") %> </ItemTemplate> <EditItemTemplate> <asp:Textbox id="txtName" runat="server" Text='<%# Container.DataItem("Name") %>'><asp:Textbox> </EditItemTemplate> </asp:TemplateColumn> not <asp:EdititemTemplate Quote
eramgarden Posted March 16, 2004 Author Posted March 16, 2004 Thanks...getting close..i dont want to have a row with several columns... i want to have a column and then the fields arragned in rows... This is what I have now: it displays fine <Columns> <asp:TemplateColumn HeaderText="FAQ Information"> <ItemTemplate> <table border="0"> <tr> <td align="right"><b>Site Name:</b></td> <td><EditItemTemplate> <asp:TextBox id="cmp_name1" Width="200px" MaxLength="20" Text='<%# Container.DataItem("cmp_name1")%>' Runat="server" Columns="6"> </asp:TextBox> </EditItemTemplate></td> </tr> <tr> <td align="right"><b>Site Addr1:</b></td> <td><EditItemTemplate> <asp:TextBox id="Textbox1" Width="200px" MaxLength="20" Text='<%# Container.DataItem("cmp_addr1")%>' Runat="server" Columns="6"> </asp:TextBox> </EditItemTemplate></td> </tr> </table> </ItemTemplate> </asp:TemplateColumn> </Columns> But under <EditItemTemplate>, I get a red line with the msg: The active schema does not support the elemenet <EditItemTemplate> Why?? Quote
kahlua001 Posted March 16, 2004 Posted March 16, 2004 You cannot have a EditItemTemplate nested under an ItemTemplate. Look at my example. The EditItemTemplate is the same as the ItemTemplate, except that instead of the normal values, i place the values into editable input fields, like textboxes, dropdownlists, etc...So...when you enter the Edit mode, it displays the EditItemTemplate instead. Quote
eramgarden Posted March 16, 2004 Author Posted March 16, 2004 ah..thanks so much for sticking with me about this issue... one more thing: How can I have it with HTML code? can I even have it with HTML code?? i want my columns to be in ONE coulmn arragned in rows.. Quote
eramgarden Posted March 16, 2004 Author Posted March 16, 2004 i think i found my answer. Thanks for all your help... will post again if my light bulb is not brighter :) Quote
eramgarden Posted March 16, 2004 Author Posted March 16, 2004 thanks This is what I've been trying to do.finally got it...thanks for all your help... <Columns> <asp:TemplateColumn HeaderText="Site Information"> <ItemTemplate> <table border="0"> <tr> <td align="left"><b>Site Name:</b></td> <td> <%# Container.DataItem("cmp_name1") %> </td> </tr> <tr> <td align="right"><b>Site Address:</b></td> <td> <%# Container.DataItem("cmp_addr1") %> </td> </tr> </table> </ItemTemplate> <EDITITEMTEMPLATE> <table border="0"> <tr> <td align="left"><b>Site Name:</b></td> <td> <asp:TextBox id="cmp_name1" Width="200px" Runat="server" Text='<%# Container.DataItem("cmp_name1")%>' MaxLength="20"> </asp:TextBox> </td> </tr> <tr> <td align="right"><b>Site Address:</b></td> <td> <asp:TextBox id="cmp_addr1" Width="200px" Runat="server" Text='<%# Container.DataItem("cmp_addr1")%>' MaxLength="20"> </asp:TextBox> </td> </tr> </table> </EDITITEMTEMPLATE> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"> <HeaderStyle Width="50px"></HeaderStyle> </asp:EditCommandColumn> </Columns> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.