[Mono-dev] DataList SelectedIndex

Tony Gu tonyxgu at yahoo.com
Mon Sep 11 15:51:54 EDT 2006


The selectedIndex of the DataList control always return -1, when I run the following test code under mono-1.1.17. Same code works fine in .NET.
Is this a bug or just this coding can't get the selectedIndex under Mono?
Any help is appreciated.

Tony

<%@ Page Language="C#" %>

<html>
<head/>
<body>
<center>
<p>Test DataList Select</p>
<form id="x" runat="server">
<asp:DataList id="DataList1" runat="server" EnableViewState="true" OnSelectedIndexChanged="dl_OnSelectedIndexChanged">
   <ItemTemplate> 
   <table>
     <tr>
       <td><asp:button id="selectButton" CommandName="Select" runat="server"/></td>
       <td>
        <%# ((DictionaryEntry)Container.DataItem).Key %>&nbsp;
        <%# ((DictionaryEntry)Container.DataItem).Value %> 
       </td>
     </tr>
   </table>
   </ItemTemplate> 
</asp:DataList>
<P/>
<asp:Label ID="label1" runat="server" />
</form>
</center>
</body>
</html>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        Hashtable ht = new Hashtable();
        ht.Add ("test1", "A");
        ht.Add ("test2", "B");
        ht.Add ("test3", "C"); 
        DataList1.DataSource = ht;
        DataList1.DataBind(); 
        }
    }

    protected void dl_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        this.Response.Output.WriteLine("The method dl_OnSelectedIndexChanged is called.");
        label1.Text = "DataList1.SelectedIndex = " + DataList1.SelectedIndex;
    }
</script>




 		
---------------------------------
Stay in the know. Pulse on the new Yahoo.com.  Check it out. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060911/f648903b/attachment.html 


More information about the Mono-devel-list mailing list