Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using the jquery datatables plugin, and its great, until I make a change using a repeater ItemCommand. It seems to only hold the data for the first page of the plugin.. ie. page 1 and not the 2, 3, 4.... * pages.. The wierd thing is the drop down values remain in the drop down, but the selected value of the drop down defaults to position 0 (both are generated and assigned via sql dataset)..

Here is my code..

C#
<pre>    /// ************************************************************************
    /// <summary>
    /// Gets the data from the repeater responce.
    /// </summary>
    /// ************************************************************************
    protected void testRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        // Update category
        if (e.CommandName == "category")
        {
            var arguments = (string)e.CommandArgument;
            var arg = arguments.Split(new[] { ';' });

            Session["PersonId"] = arg[0];
            Session["CategoryId"] = arg[1];

            int personID = Converter.ToInteger(arg[0]);
            int categoryId = Converter.ToInteger(arg[1]);

            using (TrialProvider tp = new TrialProvider())
            {
                tp.UpdateCategory(CategoryId, PersonID); 
            }
        }    
    }


    /// ************************************************************************
    /// <summary>
    /// Populates drop-down with category details.
    /// </summary>
    /// ************************************************************************
    protected void categoryList_DataBinding(object sender, System.EventArgs e)
    {
        DropDownList categoryList = (DropDownList)(sender);

        using (TrialProvider tp = new TrialProvider())
        {
            DataSet ds = tp.GetAllTrialCategories();

            // Add the items to the list     
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                categoryList.Items.Add(new ListItem(Converter.ToString(dr["Category"]), Converter.ToString(dr["CategoryId"])));

                // Set the selected property        
                categoryList.SelectedValue = Eval("CategoryId").ToString();
            }            
        }        
    }



Here is my client side code..

ASP.NET
<pre><asp:Repeater ID="testRepeater" runat="server">
                                        <HeaderTemplate>
                                            <table id="test-table" class="display">
                                                <thead>
                                                    <td>First Name</td>
                                                    <td>Surname</td>
                                                    <td>Date of Birth</td>
                                                    <td>State</td>
                                                    <td>Postcode</td>
                                                    <td>Email</td>
                                                    <td>Category</td>
                                                </thead>
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <tr>
                                                <td><%# DataBinder.Eval(Container, "DataItem.FirstName") %></td>
                                                <td><%# DataBinder.Eval(Container, "DataItem.Surname") %></td>
                                                <td><%# DataBinder.Eval(Container, "DataItem.DOB", "{0:d/M/yyyy}") %></td>
                                                <td><%# DataBinder.Eval(Container, "DataItem.State") %></td>
                                                <td><%# DataBinder.Eval(Container, "DataItem.Postcode") %></td>
                                                <td><%# DataBinder.Eval(Container, "DataItem.Email") %></td>
                                                <td>
                                                    <asp:DropDownList ID="categoryList" 
                                                        CommandName="category"
                                                        CommandArgument='<%# Eval("PersonId") + ";" + Eval("CategoryId") %>'
                                                        runat="server"
                                                        AutoPostBack="true"
                                                        OnDataBinding="categoryList_DataBinding"></asp:DropDownList>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            </table>
                                        </FooterTemplate>
                                    </asp:Repeater
>
Posted

1 solution

It's probably because of Repeater control as it's read only. Try changing Repeater control to DataGrid or Grid View and verify.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900