Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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"??

Posted

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>

Posted

<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>

Posted

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

Posted

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??

Posted
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.
Posted

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..

Posted

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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...