GrapeCity Forums

The GrapeCity Message Boards
Welcome to GrapeCity Forums Sign in | Join | Help
in Search

The problem of "DataBinding to SQLDataSource "

Last post 07-07-2009, 2:21 AM by damofeiying. 4 replies.
Sort Posts: Previous Next
  •  07-02-2009, 10:41 PM 79808

    The problem of "DataBinding to SQLDataSource "

    My problem is similar to gvidali's ( http://www.clubfarpoint.com/Forums/forums/thread/72081.aspx). This time it runs well, but the next time it fails with "Object reference not set to an instance of an object ". If I unbind with sqldatasource, it works well.  unfortunately, i meet it for several times.

    In the same project, other pages without standard SqlDataSource work well.

     I am using FarPoint Spread for ASP.NET 4.0 and Windows XP3, VS2005.

       Tks

    Damofeiying

     FarPoint.Web.Spread.Model.DefaultSheetDataModel.GetKey(Int32 index) +1240
       FarPoint.Web.Spread.SheetView.SaveViewState() +2783
       FarPoint.Web.Spread.FpSpread.SaveViewState() +2184
       System.Web.UI.Control.SaveViewStateRecursive() +137
       System.Web.UI.Control.SaveViewStateRecursive() +254
       System.Web.UI.Control.SaveViewStateRecursive() +254
       System.Web.UI.Page.SaveAllState() +600
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4996

     

  •  07-03-2009, 11:28 AM 79832 in reply to 79808

    Re: The problem of "DataBinding to SQLDataSource "

    Hello,

    When are you getting this exception? make sure you are setting the DataSourceId property of the Spread to the ID of the SQlDataSource object. Could you post a small zipped project reproducing the behavior you are seeing for us to debug?


    Scott S.
    Product Manager, Spread ASP.NET
    GrapeCity FarPoint
  •  07-03-2009, 10:29 PM 79841 in reply to 79832

    Re: The problem of "DataBinding to SQLDataSource "

    The code in .aspx:

            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=(local);AttachDbFilename=|DataDirectory|\person.mdf;Integrated Security=True;User Instance=True"
                DeleteCommand="DELETE FROM zhxxlqk WHERE (xlshj = @xlshj)" InsertCommand="INSERT INTO zhxxlqk(xlnr, xlshj, shj, xlxg, bzh) VALUES (@xlnr, @xlshj, @shj, @xlxg, @bzh)"
                SelectCommand="SELECT zhxxlqk.* FROM zhxxlqk" UpdateCommand="UPDATE zhxxlqk SET xlnr = @xlnr, shj = @shj, xlxg = @xlxg, bzh = @bzh WHERE (xlshj = @xlshj)">
                <DeleteParameters>
                    <asp:Parameter Name="xlshj" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="xlnr" />
                    <asp:Parameter Name="shj" />
                    <asp:Parameter Name="xlxg" />
                    <asp:Parameter Name="bzh" />
                    <asp:Parameter Name="xlshj" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="xlnr" />
                    <asp:Parameter Name="xlshj" />
                    <asp:Parameter Name="shj" />
                    <asp:Parameter Name="xlxg" />
                    <asp:Parameter Name="bzh" />
                </InsertParameters>
            </asp:SqlDataSource>
            <FarPoint:FpSpread ID="FpSpread1" runat="server" ActiveSheetViewIndex="0" BorderColor="Black"
                BorderStyle="Solid" BorderWidth="1px" DesignString='<?xml version="1.0" encoding="utf-8"?><Spread />'
                Height="300px" Width="770px">
                <Sheets>
                    <FarPoint:SheetView AutoGenerateColumns="False" DataKeyNames="xlshj" DataSourceID="SqlDataSource1"

    ......

    The code in .aspx.cs:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                FpSpread1.ActiveSheetView.AllowInsert = true;
                FpSpread1.ActiveSheetView.AllowDelete = true;

            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            FpSpread1.SaveChanges();
        }

  •  07-06-2009, 9:13 AM 79868 in reply to 79841

    Re: The problem of "DataBinding to SQLDataSource "

    I am not able to replicate the issue by implementing your code in the latest build of Spread 4 for ASP.Net version 4.0.3506.2008

    If you are not using the latest build, please upgrade to the above said version of Spread.

    Regards, 


    Scott S.
    Product Manager, Spread ASP.NET
    GrapeCity FarPoint
  •  07-07-2009, 2:21 AM 79904 in reply to 79868

    Re: The problem of "DataBinding to SQLDataSource "

    This problem is finally solved, the ConnectionString does not work very well.

    Everything is OK if I use "Data Source= .\SQLEXPRESS" instead of "Data Source=(local)".

    But GridView works well with  "Data Source=(local)"  or "Data Source= .\SQLEXPRESS". I don't know why such a thing could happen?

     

View as RSS news feed in XML
     FarPoint Forums Home