Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
410
hi i need the code to save the details from wingrid in c#
posted

hi every one since i am new to infragistics controls i dont know how to save the details from wingrid.please any one help me on this

my requirement is like this i need to enter the data in wingrid then i pree a button control it should save in sql DB.

 

any one please help to i dont know how can i save the details from but i know how to retrive the data from DB

 

Thanks

 

  • 469350
    Offline posted

    Hi,

    What do you mean by "details"?

    If you mean saving the data in the grid to the back end, then the grid is not involved in that process. The WinGrid only deals with it's local data source. The DataSource typically deals with updating the back end. How it does this depends on what kind of data source you are using. A DataTable/DataSet usually works with a DataAdapter to build the SQL Commands and update the back end. For more information on that, you will need to refer to Microsoft documentation.

    The code posted above by SAbady will save the grid's layout which includes the column widths and positions, sortied, filtering, and other thing that the user may customize. But it does not include the data.

  • 835
    Suggested Answer
    Offline posted

    Hi,

    This is what I've done (roughly)...

    // Save the layout to a memory stream 

    MemoryStream stream = new MemoryStream();

    this.gridProcedures.DisplayLayout.SaveAsXml(stream);

    // I save memory stream as an array of bytes in SQL Server by:

     

     

     

     

    SqlParameter propertyParameter = command.Parameters.Add("@GridLayoutProperty", System.Data.SqlDbType.VarBinary);

    propertyParameter.SqlValue = stream.ToArray();

     

     

     

     

    command.CommandText =

     

    string.Format("UPDATE {0} SET GridLayoutProperty = @GridLayoutProperty WHERE UserID = @UserID AND ScreenID = @ScreenID AND PropertyID = @PropertyID", "DBTable");