[CLOSED] asp:datalist inside ext window item.count always zero

  1. #1

    [CLOSED] asp:datalist inside ext window item.count always zero

    Hi,

    I have asp:datalist inside a ext:window, i am binding the asp:datalist on click of button and showing the window at the same time which works fine.

    But on click of another button which is in the window i count the items in datalist "Datalist.items.count" which is always Zero, however datalist is visible on the screen with data.

    Please help in this , Below is my code

    .Aspx
    __________________________________________________ _________________________________________________

    <ext:Window ID="winGetSplit" runat="server" Modal="true" Hidden="true" EnableViewState="true" Padding="5"
            Title="split Process" Height="250" Width="450">
            <Items>
                <ext:TextField ID="tfCurrentCTC" runat="server" FieldLabel="Current CTC" Width="300"
                    Padding="5" ReadOnly="true">
                </ext:TextField>
                <ext:ComboBox ID="cbPayrollPolicy" runat="server" FieldLabel="Payroll Policy" Padding="5"
                    Width="300">
                    <Store>
                        <ext:Store ID="strPayrollPolicy" runat="server">
                            <Model>
                                <ext:Model ID="mdPayrollPolicy" runat="server">
                                    <Fields>
                                        <ext:ModelField Name="pk_CatalogMaster">
                                        </ext:ModelField>
                                        <ext:ModelField Name="catlShortDesc">
                                        </ext:ModelField>
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                </ext:ComboBox>
                <ext:DateField ID="dfCompDate" runat="server" FieldLabel="Effective Date" Padding="5"></ext:DateField>
            </Items>
            <Content>
                <table>
                    <tr>
                        <td>
                        
                                    <asp:DataList ID="dlSpitCTC" runat="server" EnableViewState="true">
                                        <ItemTemplate>
                                            <table>
                                                <tr>
                                                    <td style="display: none">
                                                    </td>
                                                    <td style="padding: 3px">
                                                        <asp:Label ID="lblElementName" Visible="true" runat="server" Text='<%# Eval("Component code") %>'
                                                            Width="100px"></asp:Label>
                                                    </td>
                                                    <td style="padding: 3px">
                                                        <asp:TextBox ID="txtCompElement" runat="server" Text='<%# Eval("Amount") %>'></asp:TextBox>
                                                         
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                    </asp:DataList>
                        
                        </td>
                    </tr>
                </table>
            </Content>
            <Buttons>
                <ext:Button ID="btnSaveCTC" runat="server" Text="Save" Icon="Disk" OnDirectClick="btnSaveCTC_DirectClick">
                    
                </ext:Button>
                <ext:Button ID="Button12" runat="server" Text="Cancel" Icon="Cancel">
                </ext:Button>
            </Buttons>
        </ext:Window>

    Binding DataList

    __________________________________________________ __________________________________________________ ________
    private void Split()
            {
                DataSet dssplit = fn.SplitCTC("576", tfCurrentCTC.Text);/// Function to bind data, you can use yours
    
               
                if (X.IsAjaxRequest)
                {
                  
                    dlSpitCTC.DataSource = dssplit;
                    dlSpitCTC.DataBind();
                    dlSpitCTC.Update();
                    cbPayrollPolicy.Render();
                   
                    winGetSplit.Render();
                    winGetSplit.Show();
                }
            }


    btnSaveCTC_DirectClick event where i count the items

    __________________________________________________ __________________________________________________ ___________

    
     try
                {
                    
                    for (int i = 0; i < dlSpitCTC.Items.Count; i++)
                    {
                        
    ////Some Code
    
                    }
    
                   
                }
                catch (Exception ex)
                {
                    X.Msg.Alert("Status", ex.Message, new JFunction { Fn = "" }).Show();
                }
    Last edited by Daniil; Jul 23, 2013 at 12:54 PM. Reason: [CLOSED]
  2. #2
    Hi @Tonic,

    A DataSource bound during one DirectEvent, doesn't persist during another one automatically. Neither Ext.NET or ASP.NET recreates it.

    As a solution you could re-bind a DataSource during each request.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Tonic,

    A DataSource bound during one DirectEvent, doesn't persist during another one automatically. Neither Ext.NET or ASP.NET recreates it.

    As a solution you could re-bind a DataSource during each request.


    You mean to say that on btnSaveCTC_DirectClick i again bind the datalist
  4. #4
    Well, I think (but not 100% sure) yes, you could do it directly before you need to access a DataList's things.
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, I think (but not 100% sure) yes, you could do it directly before you need to access a DataList's things.
    Daniil

    Actually in my case there is textbox inside the datalist which user can manipulate , so if i rebind it the changes by user will be lost
  6. #6
    As another option you could try to enable ViewState.

    1. Set up this:
    <ext:ResourceManager runat="server" DisableViewState="false" />
    2. Enable ViewState for a DirectEvent where you bind the data setting up ViewStateMode="Enabled" for a DirectEvent's config. For example, a Button's Click DirectEvent:
    <Click OnEvent="TestDirectEventHandler" ViewStateMode="Enabled" />
    By the way, do you really need to re-bind the DataList? What about to get the required data direct from the DataSource that you bind to the DataList?

Similar Threads

  1. Replies: 22
    Last Post: Apr 27, 2016, 12:36 AM
  2. Replies: 3
    Last Post: Jan 21, 2011, 1:19 PM
  3. [CLOSED] [1.0] Custom Search dynamic item count
    By betamax in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 09, 2010, 1:34 PM
  4. Replies: 1
    Last Post: Jun 04, 2010, 5:21 PM
  5. [CLOSED] Item Count for Store - Server Side
    By JD in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 02, 2010, 9:07 AM

Posting Permissions