I am having great trouble getting to grips with DataLists with ASP.NET 1.1. I think they are the best tool I have available to do what I need to but am really struggling to get them to do what I think they should do. Can anyone please point me in the direction of some good tutorials? In case I have missed something really obvious (which is quite likely) here is what I have done so farJust to play around and see how they worked I setup a simple one. Here is the ASP <asp:datalist id="dlClinOutcome" runat="server" GridLines="Both" Caption="DataList" ShowHeader="False"> <EditItemStyle Wrap="False" BackColor="HotPink"></EditItemStyle> <SelectedItemTemplate> <asp:LinkButton id="LinkButton1" runat="server" CommandName="edit">Edit</asp:LinkButton> </SelectedItemTemplate> <AlternatingItemStyle Wrap="False"></AlternatingItemStyle> <SeparatorStyle BorderColor="Red"></SeparatorStyle> <ItemStyle Wrap="False"></ItemStyle> <ItemTemplate> <asp:LinkButton id="hlnkSelect" runat="server" CommandName="select">Select</asp:LinkButton> <asp:LinkButton id="LinkButton4" runat="server" CommandName="edit">Edit</asp:LinkButton> </ItemTemplate> <SeparatorTemplate> <hr> </SeparatorTemplate> <EditItemTemplate> <asp:LinkButton id="LinkButton2" runat="server">LinkButton</asp:LinkButton> <asp:LinkButton id="LinkButton3" runat="server">LinkButton</asp:LinkButton> </EditItemTemplate> </asp:datalist>
Essentially a select link to select an item and an edit link to edit an item. Nothing too fancy thereFor the code I have Private Sub dlClinOutcome_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlClinOutcome.ItemCommand Dim cmd As String = e.CommandSource.CommandName If cmd = "select" Then Me.dlClinOutcome.SelectedIndex = e.Item.ItemIndex ElseIf cmd = "quit" Then Me.dlClinOutcome.SelectedIndex = -1 ElseIf cmd = "edit" Then Me.dlClinOutcome.EditItemIndex = e.Item.ItemIndex End If End Sub
Again nothing fancy, select causes the item to be selected and edit causes it to be edited. However, I have discovered that I have to click a link twice to get it to do what I want, so if I want to edit I have to click the edit link twice and the same for Select. What's more the first click seems to be ignored as if I click one link then the other, only the second click is activated so if I click Select once then Edit once it goes to edit mode. I'm convinced I've missed something very simple but have no idea what. Anyone have any clues? thanks steve-----------Don't worry head. The computer will do all the thinking from now on.