[CLOSED] mixed ext.net asp.net cotnrols and postback

  1. #1

    [CLOSED] mixed ext.net asp.net cotnrols and postback

    Hi,

    I am using an aspnet datalist to place data in multiple columns.
    I would like reading user values when user presses "send data" button but my datalist has no item on postback.

    Is there a way to get datalist hold his values on postback? Is there a different kind of postback I can use?

    Click image for larger version. 

Name:	Grid.png 
Views:	84 
Size:	48.3 KB 
ID:	4302

    Here is my code

    markup
              <ext:Window 
                ID="wGrigliaPoteri" 
                runat="server" 
                Title="Griglia dei poteri"  
                Icon="Application"
                Height="500" 
                Width="800"
                BodyStyle="background-color: #fff;" 
                BodyPadding="5"
                Modal="true"
                Hidden="true"
                >
                <Listeners>
                <Show Handler="#{stPotere}.load();"></Show>
                </Listeners>
                <Content>
                <table style="width:100%"><tr><td  style="vertical-align:top; border: 1px solid lightgray; padding:10px">
                    <asp:DataList ID="dlGrigliaPoteriNeg" runat="server" Width="100%"  ShowHeader="true"
                         RepeatColumns="3"  ItemStyle-HorizontalAlign="Right" DataKeyField="ProductNumber" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true" HeaderStyle-Height="30px" >
                         <HeaderTemplate>Negativi</HeaderTemplate>
                        <ItemTemplate>
                        <table  class="elGrigliaPoteri" >
                        <tr>
                        <td ><asp:Label ID="DescriptionLabel" runat="server" 
                                Text='<%# Eval("Description") %>' /></td><td><ext:NumberField ID="nfGrigliaQuantity"  runat="server" Width="60" MinValue="1"  /></td>
                        </tr>
                        </table>
                        </ItemTemplate>
                    </asp:DataList>
                    </td>
                    <td  style="vertical-align:top; border: 1px solid lightgray; padding:10px">
                    <asp:DataList ID="dlGrigliaPoteriPos" runat="server" Width="100%"  ShowHeader="true"
                         RepeatColumns="3"  ItemStyle-HorizontalAlign="Right" DataKeyField="ProductNumber" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true" HeaderStyle-Height="30px">
                         <HeaderTemplate>Positivi</HeaderTemplate>
                        <ItemTemplate>
                        <table  class="elGrigliaPoteri" >
                        <tr>
                        <td><asp:Label ID="DescriptionLabel" runat="server" 
                                Text='<%# Eval("Description") %>' /></td><td><ext:NumberField ID="nfGrigliaQuantity"  runat="server" Width="60" MinValue="1"  /></td>
                        </tr>
                        </table>
                        </ItemTemplate>
                      </asp:DataList>
                 </td></tr></table>
                </Content>
                <Buttons>
                <ext:Button ID="AddToCartFromGrid" runat="server" Text="Aggiungi al Carrello" Icon="CartAdd" >
                    <DirectEvents>
                        <Click OnEvent="AddToCartFromGrigliaPoteri" ></Click>
                    </DirectEvents>
                    <Listeners>
                            <Click Handler="#{gpBasket}.store.load();" />
                    </Listeners>
                </ext:Button>
                </Buttons>
            </ext:Window>   
    <asp:ObjectDataSource ID="odsGrigliaPoteriNeg" runat="server" TypeName="renosistemi.it.Shared.EXTJSWebService" SelectMethod="getPoteriProdottoListNeg"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsGrigliaPoteriPos" runat="server" TypeName="renosistemi.it.Shared.EXTJSWebService" SelectMethod="getPoteriProdottoListPos"></asp:ObjectDataSource>


    codebehind

            protected void AddToCartFromGrigliaPoteri(object sender, DirectEventArgs e)
            {
                Guid? basketID = new Guid(Request["Id"]);
                int count = 0;
                using (renosistemi.it.Shared.EXTJSWebService myWS = new Shared.EXTJSWebService())
                {
                    foreach (DataListItem myItem in dlGrigliaPoteriNeg.Items)
                    {
                        Ext.Net.NumberField nfGrigliaQuantity = (Ext.Net.NumberField)myItem.FindControl("nfGrigliaQuantity");
                        
                        int quantity = Convert.ToInt32((double)nfGrigliaQuantity.Value);
                        if (quantity > 0)
                        {
                            string productID = (string)dlGrigliaPoteriNeg.DataKeys[myItem.ItemIndex];                        
                            myWS.insertBasketLine(basketID, productID, quantity);
                            count++;
                        }
                    }
                    foreach (DataListItem myItem in dlGrigliaPoteriPos.Items)
                    {
                        Ext.Net.NumberField nfGrigliaQuantity = (Ext.Net.NumberField)myItem.FindControl("nfGrigliaQuantity");
    
                        int quantity = Convert.ToInt32((double)nfGrigliaQuantity.Value);
                        if (quantity > 0)
                        {
                            string productID = (string)dlGrigliaPoteriNeg.DataKeys[myItem.ItemIndex];
                            myWS.insertBasketLine(basketID, productID, quantity);
                            count++;
                        }
                    }
                        
                }
    
                GridPanel gpBasket = X.GetCtl<GridPanel>("gpBasket");
                if (gpBasket != null)
                {
                    var store = gpBasket.GetStore();
                    store.Reload();
                }
                X.Msg.Notify("Ok", string.Format("Inseriti {0} articoli", count)).Show();
                wGrigliaPoteri.Hide();
    
            }
    Last edited by Daniil; Jun 04, 2012 at 8:38 PM. Reason: [CLOSED]
  2. #2
    I guess you need to rebind DataList to get controls but i am not sure about it (i don't know how is implemented DataList). How do you read values if replace Ext.Net field by ASP.NET TextBox?

    Imho, In your case it is better to read values directly from Request
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    If I rebind the datalist I lose user data input (textbox values).

    I tried to replace ext.net numberfileds with asp.net textbox with no result.

    It looks complex reading data from request because I need to bind that to product codes wich are stored on datalist items.

    M
  4. #4
    Try to rebind in Page_Init (before LoadPostData logic will be executed)
    Vladimir Shcheglov
    Sr. Developer

Similar Threads

  1. Help - Problem with Mixed value in TextField
    By ranlandau in forum 2.x Help
    Replies: 0
    Last Post: Jul 23, 2012, 3:54 PM
  2. [CLOSED] ext:Panel with Items and Loader (mixed mode)
    By supera in forum 2.x Premium Help
    Replies: 2
    Last Post: Apr 24, 2012, 3:45 PM
  3. [CLOSED] HTML Object Tag: Error when mixed with EXT.NET
    By nhg_itd in forum 1.x Premium Help
    Replies: 2
    Last Post: Nov 08, 2011, 9:39 AM
  4. Replies: 1
    Last Post: Jul 06, 2011, 5:55 PM
  5. ColumnLayout and Mixed LayoutColumn Items
    By conman in forum 1.x Help
    Replies: 2
    Last Post: Jul 09, 2008, 11:08 AM

Posting Permissions