[CLOSED] GridPanel Datasource from Code Behind

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] GridPanel Datasource from Code Behind

    Hi,
    I have been trying to update a grid panel on click of button. However, I receive and error saying Bad Response Syntax Error.

    The following is my code :
    -----Grid.aspx----
    
    <ext:Store runat="server" ID="store_conditions" DataSourceID ="conditions_linq">
            <Reader ><ext:jsonReader >
            <Fields ><ext:RecordField Name ="conditions"  />
            <ext:RecordField Name ="conditionsid" /></Fields>
            </ext:jsonReader></Reader>
            </ext:Store> 
        <ext:Gridpanel  runat ="server" ID="chkconditions" height="200px" 
                AutoScroll ="True"  StoreID ="store_conditions" Title ="Conditions">
    <ColumnModel id="con_col_model" runat="server" >
    <Columns>
    <ext:Column ColumnID ="condition" DataIndex ="conditions" Header ="Conditions" ></ext:Column>
    <ext:Column ColumnID ="conditionid" DataIndex ="conditionsid" Header="conditionsid"></ext:Column>
    </Columns>
    
    </ColumnModel>
    
    </ext:Gridpanel>
    <ext:button ID="btnconditions"  runat="server" Text="Add / Search">
    <AjaxEvents >
    <Click OnEvent ="btnconditions_Click">
    <EventMask  ShowMask ="true" /> 
    </Click>
    </AjaxEvents>
    </ext:button>
    
    --------Grid.aspx.vb----------
    
     Public Sub btnconditions_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim conditions_linq = From items In db.conditions_masters Select items.conditions, items.conditionsid Take (10)
            Me.store_conditions.DataSource = conditions_linq
            Me.store_conditions.DataBind()
            Me.chkconditions.DataBind()
        End Sub
    Any help would be much appreciated. If I specify a HTTPProxy, I get an error saying "b is undefined".

    Thanks,
  2. #2

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Attached is the screenshot. The data inside Request failure is :

    <cooliteajaxrequest>
    store_conditions.callbackRefreshHandler(response,
    {serviceResponse: {Data:{data:[{"conditions":"Aarskog
    Syndrome","conditionsid":1},{"conditions":"Aase
    Syndrome","conditionsid":2},{"conditions":"Abdominal Aortic Aneurysm
    (AAA)","conditionsid":3},{"conditions":"Abdominal
    Bloating","conditionsid":4},{"conditions":"Abdominal
    Cramps","conditionsid":5},{"conditions":"Abdominal
    Hernia","conditionsid":6},{"conditions":"Abdominal
    Mass","conditionsid":7},{"conditions":"Abdominal
    Pain","conditionsid":8},{"conditions":"Abdominal
    Swelling","conditionsid":9},{"conditions":"Abducens Nerve
    Palsy","conditionsid":10}], totalCount: 0},Success:true}},
    store_conditions, type, action, userParams);</cooliteajaxrequest>
    Thanks
  3. #3

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hi amitpareek,

    I think you might just need to change the "EventArgs" to "AjaxEventArgs".


    Example


    Public Sub btnconditions_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)

    Hope this helps.


    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Naah... It does'nt work... Same error...

    Can you put up some example similar to mine, where grid is updated on click of button from server side code.

    I can then compare and check. Or do you think it is the prob with 6.0? I remember doing something like this with pre-preview 6.0 tht u had sent me and tht time it had worked.

    Thanks,
  5. #5

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hi,

    It is simple example which shows Grid refreshing on button click

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        public object[] TestData
        {
            get
            {
                return new object[]
                    {
                        new object[] {"3m Co", 71.72, 0.02, 0.03, DateTime.Now.ToString()},
                        new object[] {"Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am"}
                    };
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = this.TestData;
                this.Store1.DataBind();
            }
        }
    
        protected void Button_Click(object sender, AjaxEventArgs e)
        {
            this.Store1.DataSource = this.TestData;
            this.Store1.DataBind();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Coolite Example - Simple Array Grid</title>
        <link href="../../Css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">    
        <ext:ScriptManager ID="ScriptManager1" runat="server" />
        
        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="company" />
                        <ext:RecordField Name="price" Type="Float" />
                        <ext:RecordField Name="change" Type="Float" />
                        <ext:RecordField Name="pctChange" Type="Float" />
                        <ext:RecordField Name="lastChange" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>    
          
        <ext:GridPanel 
            ID="GridPanel1" 
            runat="server" 
            StoreID="Store1"
            StripeRows="true"
            Title="Array Grid"
            AutoExpandColumn="Company"
            Width="600" 
            DisableSelection="true"
            Height="350">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnId="Company" Header="Company" Width="160" Sortable="true" DataIndex="company" />
                    <ext:Column Header="Price" Width="75" Sortable="true" DataIndex="price"/>
                    <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="change"/>
                    <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="pctChange"/>
                    <ext:Column Header="Last Updated" Width="85" Sortable="true" DataIndex="lastChange"/>
                </Columns>
            </ColumnModel>        
        </ext:GridPanel>
        
        <ext:Button runat="server" Text="Refresh">
            <AjaxEvents>
                <Click OnEvent="Button_Click"/>
            </AjaxEvents>
        </ext:Button>
        
        </form>
    </body>
    </html>
  6. #6

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hey,
    Thanks for that sample.

    I checked it. On Page Load, The Data is loaded in the grid. But on Button Click I get similar error, what I was getting with code.

    Syntax Error

    
            <cooliteajaxrequest>Store1.callbackRefreshHandler(response,
    {serviceResponse: {Data:{data:[["3m Co",71.72,0.02,0.03,"10/25/2008
    7:12:46 PM"],["Alcoa Inc",29.01,0.42,1.47,"9/1 12:00am"]], totalCount:
    0},Success:true}}, Store1, type, action, userParams);</cooliteajaxrequest>
    Thanks,


  7. #7

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hi,
    Can you zip simple application (with assemblies) which reproduce the problem and post it?
    Or you can send me by email (vladimir at coolite dot com)

  8. #8

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hi,

    unfortunately your example doesn't work (exception in your assembly). But in your web.config i don't see AjaxRequestModule.

        <httpModules>
            <add name="AjaxRequestModule" type="Coolite.Ext.Web.AjaxRequestModule, Coolite.Ext.Web" />
        </httpModules>
    see http://forums.ext.net/showthread.php...=2542-4-1.aspx

  9. #9

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hey,
    Thank you so much!!!

    I deserve some hits on my back for avoiding this.
    Actually I thought, its added automatically wheneva we add any coolite component on the page and so I completely avoided even looking that section.

    Thanks once again,
  10. #10

    RE: [CLOSED] GridPanel Datasource from Code Behind

    Hi Amit,

    We have added logic to the project to automatically add the required <httpModules> section to the Web.config if missing.*


    The code will run when in Visual Studio Design mode.


    Hope this helps.


    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: Jul 15, 2013, 10:13 AM
  2. Replies: 2
    Last Post: Apr 11, 2012, 11:10 AM
  3. [CLOSED] DataSource for Combobox from code behind
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 11, 2012, 4:49 PM
  4. Replies: 5
    Last Post: Feb 01, 2012, 11:54 AM
  5. Gridpanel + datasource
    By Francis in forum 1.x Help
    Replies: 1
    Last Post: Oct 01, 2010, 9:09 PM

Posting Permissions