Jump to content
Xtreme .Net Talk

dEaDfRoG

Members
  • Posts

    3
  • Joined

  • Last visited

dEaDfRoG's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi chaps - and apologies if this is a stupid question, but I just cannot get it to work!! I posted this in the general section and was advised to post here instead. I'm trying to create an ASP.NET admin page, using a DataList with EditItemTemplate. I've gotten it to work nicely for a single textbox, but I also need to add a drop down list, and pre-populate it with items from my database. Think of it as if I were creating a list of towns - and each town must come from a region. When a user creates/edits a town, they must also select a region that the town is part of from a drop down list. I can get the DDL to appear, but how on earth do I populate it with data as part of an EditItemTemplate within a DataList? I hope someone knows what I'm rambling on about, and I would truly appreciate any help or advice anyone can give. I think what I'm struggling with is where I put the code to populate the DDL. The problem seems to be that the ddlRegionID as I call it isn't actually rendered until the edit button is clicked in the datalist. My apologies if I sound thick, it's probably something really obvious, but it's really annoying (especially considering how easy this would be in classic ASP!) Here's what I have: <aspataList id="dlstLocations" OnEditCommand="dlstLocations_EditCommand" OnCancelCommand="dlstLocations_CancelCommand" OnDeleteCommand="dlstLocations_DeleteCommand" OnUpdateCommand="dlstLocations_UpdateCommand" DataKeyField="LocationID" runat="server"> <itemtemplate> <%# Container.DataItem("Location")%><br /> <asp:LinkButton Text="Edit" CommandName="edit" runat="server" /> </itemtemplate> <edititemtemplate> <asp:TextBox id="txtLocation" text='<%# Container.DataItem("Location") %>' runat="server" /> <aspropDownList id="ddlRegionID" runat="server" /><br /> <asp:LinkButton text="Update" CommandName="update" runat="server" /> <asp:LinkButton text="Delete" CommandName="delete" runat="server" /> <asp:LinkButton text="Cancel" CommandName="cancel" runat="server" /> </edititemtemplate> </aspataList> Thanks for reading! Andy.
  2. I think what I'm struggling with is where I put the code to populate the DDL. The problem seems to be that the ddlRegionID as I call it isn't actually rendered until the edit button is clicked in the datalist. My apologies if I sound thick, it's probably something really obvious, but it's really annoying (especially considering how easy this would be in classic ASP!) Here's what I have: <asp:DataList id="dlstLocations" OnEditCommand="dlstLocations_EditCommand" OnCancelCommand="dlstLocations_CancelCommand" OnDeleteCommand="dlstLocations_DeleteCommand" OnUpdateCommand="dlstLocations_UpdateCommand" DataKeyField="LocationID" runat="server"> <itemtemplate> <%# Container.DataItem("Location")%><br /> <asp:LinkButton Text="Edit" CommandName="edit" runat="server" /> </itemtemplate> <edititemtemplate> <asp:TextBox id="txtLocation" text='<%# Container.DataItem("Location") %>' runat="server" /> <asp:DropDownList id="ddlRegionID" runat="server" /><br /> <asp:LinkButton text="Update" CommandName="update" runat="server" /> <asp:LinkButton text="Delete" CommandName="delete" runat="server" /> <asp:LinkButton text="Cancel" CommandName="cancel" runat="server" /> </edititemtemplate> </asp:DataList>
  3. Hi chaps - and apologies if this is a stupid question, but I just cannot get it to work!! I'm trying to create an ASP.NET admin page, using a DataList with EditItemTemplate. I've gotten it to work nicely for a single textbox, but I also need to add a drop down list, and pre-populate it with items from my database. Think of it as if I were creating a list of towns - and each town must come from a region. When a user creates/edits a town, they must also select a region that the town is part of from a drop down list. I can get the DDL to appear, but how on earth do I populate it with data as part of an EditItemTemplate within a DataList? I hope someone knows what I'm rambling on about, and I would truly appreciate any help or advice anyone can give. Thanks for reading! Andy.
×
×
  • Create New...