Link to home
Start Free TrialLog in
Avatar of hydev
hydevFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Editing a nested DataList in ASP.NET C#

Hi,

I have a nested DataList:

<asp:datalist id="DataList1" runat="server" Width="450">
      <HeaderTemplate>
       (removed to save space)
                </HeaderTemplate>

      <ItemTemplate>
      <asp:DataList id=DataList3 runat="server" DataSource='<%# DataBinder.Eval(Container,"DataItem.RelationLink")%>' OnUpdateCommand="Data_Update" OnCancelCommand="Data_Cancel" OnEditCommand="Data_Edit">
            <HeaderTemplate>
            </HeaderTemplate>
                                <ItemTemplate>
                                                                              <td width="20">&nbsp;</td>
<td class="BODYTEXT10" align="right" width="50"><%# DataBinder.Eval(Container.DataItem,"Size")%></td>
<td class="BODYTEXT10" align="center" width="50"><%# DataBinder.Eval(Container.DataItem,"Qty")%></td>
<td>&nbsp;</td>
<td class="BODYTEXT8ITALIC" align="center" width="30"><%# DataBinder.Eval(Container.DataItem,"Min")%></td>
<td class="BODYTEXT8ITALIC" align="center" width="30"><%# DataBinder.Eval(Container.DataItem,"Max")%></td>
<td class="BODYTEXT8ITALIC" align="center" width="50"><%# DataBinder.Eval(Container.DataItem,"OnOrder")%></td>
<td class="BODYTEXT8ITALIC" align="left" width="120"><%# DataBinder.Eval(Container.DataItem,"DueDate")%></td>
<TD><asp:Button id="ButEdit" runat="server" Text="Edit"></asp:Button></TD></ItemTemplate>
                                                                              <EditItemTemplate>
                  <asp:TextBox cssclass="BODYTEXT10" id="TextBoxEditQty" runat="server" columns=3 Text='<%# DataBinder.Eval(Container.DataItem,"Qty")%>'></asp:TextBox></td><td>&nbsp;</td>
<td class="BODYTEXT8ITALIC" width="30"><%# DataBinder.Eval(Container.DataItem,"Min")%></td>
<td class="BODYTEXT8ITALIC" width="30"><%# DataBinder.Eval(Container.DataItem,"Max")%></td>
<td class="BODYTEXT8ITALIC" width="50"><%# DataBinder.Eval(Container.DataItem,"OnOrder")%></td>
<td class="BODYTEXT8ITALIC" width="120"><%# DataBinder.Eval(Container.DataItem,"DueDate")%></td>
<td><asp:Button id="ButCancel" runat="server" Text="Cancel" cssclass="BODYTEXT10"></asp:Button></td>
<td><asp:Button id="ButUpdate" runat="server" Text="Update" cssclass="BODYTEXT10"></asp:Button></td>
                          </EditItemTemplate>
                                                                              </asp:DataList>                                                            </ItemTemplate>
</asp:datalist>

The problem is that when you click on the "Edit" button in the second datalist it does not go into Edit mode.  Im guessing the whole thing is reloading and resetting itself. Reading on the net I understand I only need to refresh the nested datalist but how?  

The top of the C# file says:

protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Button ButEdit;
protected System.Web.UI.WebControls.TextBox TextBox1;

There is no reference for the nested datalist so the line DataList3.DataSource = xxx causes an error because it doens't exist.  If I add  the line protected System.Web.UI.WebControls.DataList DataList3;  It then fails becuase of duplicate naming.

Basically I am a bit confused on this one.  Can anyone help? - It would be be appreciated.

Mike
      
ASKER CERTIFIED SOLUTION
Avatar of tusharashah
tusharashah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial