User Profile & Activity

James Member
Page
of 14
Posted: September 8, 2009 11:05 PM

George, I suspect that you don't use the correct settings in WebGridColumn for the html editing purpose. AFAIK, the ColumnType should be set to Custom and there could be more settings. Try to look at Handy's sample.

- James

Posted: September 8, 2009 1:36 PM

Amanda, WebGrid produces very minimal viewstate which usually consist only the setting required to be persisted. If your Grid is created in design time (i.e, all settings are declared in aspx), you can even set ViewStateStorage to None. That way, WebGrid will not produce any view state at all and still fully functional.

Posted: September 8, 2009 12:20 PM

Michael,

It appears that the OnBeforeXXX and OnAfterXXX for editing-type operations will be fired only in normal updating mode (non batch updating).

I think the reason is because batch update has its own specific events such as OnAcceptAllChanges, OnAddPendingChanges, OnUndoChanges and OnUndoAllChanges which supercede the basic editing events.

Hope this helps, 
James.

Posted: September 8, 2009 11:10 AM

Aiyer, 

Firstly, make sure that the always load cache on page load setting is set to false. The setting can be accessed in grid.LayoutSettings.AlwaysUseCachedDataOnFirstLoad.

Then, you should use grid.GetCachedDataSource() method in order to get the cached data source instead of .DataSource and cast it to appropriate datasource type.

Let me know if that helps.

- James.


Posted: September 8, 2009 10:22 AM

Hello Eric,

After investigating your code further, it appears that you implement the ValueList in incorrect event. Instead of initializing the value list in PrepareDataBinding, you should place it in InitializeLayout event to ensure the value list is initialized when needed.

Code sample:

protected void WebGrid2_InitializeLayout(object sender, LayoutEventArgs e)
    {
        WebValueList vLang = null;
        WebGridColumn languageColumn = WebGrid2.RootTable.Columns.GetNamedItem("CultureCode");
        if (languageColumn != null)
            vLang = languageColumn.ValueList;
        
        if (vLang != null)
        {
            // setup valuelist data
            vLang.DataTextField = "CultureCodeDescription";
            vLang.DataValueField = "CultureCodeId";
            if (!vLang.IsDataCached())
            {
                DataTable dt = new DataTable("Languages");
                SqlDataAdapter theLanguages = new SqlDataAdapter();
                SqlConnection conn = new SqlConnection(SqlDataSource1.ConnectionString);
                try
                {
                    string queryLangs = "SELECT CultureCodeId, CultureCodeDescription FROM Culture";
                    theLanguages.SelectCommand = new SqlCommand(queryLangs, conn);
                    theLanguages.Fill(dt);
                }
                finally { if (conn.State == ConnectionState.Open) { conn.Close(); } }
                vLang.DataSource = dt;
            }
        }
    }


Let me know if that works for you.

- James.

Okay, will be waiting for your attachment. 

Yes, I'm aware about the _moz input textbox. It appears to be used in the editing mode, which is internally used by the WebGrid. I also think hiding it would cause certain error in your web pages, which is not recommended.

It'll be great if you can reproduce the issue consistently in a simple webform, and attach it here. I'll help to look at your issue. Thanks.

Posted: September 7, 2009 2:03 AM

It seems your previous WebGrid build has been quite old. There might be several enhancements related to transactions in the latest update.

You can see the solution for this issue in a similar community thread at http://www.intersoftpt.com/Community/WebGrid/Cant-delete-rows/

Hope this helps,
James.

Can you reproduce this issue in provided WebGrid samples? If so, please post the steps to reproduce. Thanks!
Posted: September 4, 2009 8:40 AM

George,

Okay, I just realized that you're using OnTheFly configuration, which the Select in server-side may not be applicable (because the Grid wasn't refreshed in that case).

You can easily achieve this scenario by using ClientAction which maybe suitable in such OnTheFly context and for best performance. Here's how:

protected void WebGrid1_ButtonClick(object sender, ISNet.WebUI.WebGrid.ButtonEventArgs e)
    {
        SelectedObject selectedObject = WebGrid1.RetrieveClientLastSelectedObject() as SelectedObject;
        WebGrid1.ClientAction.InvokeScript("SelectRow", new FunctionParameter[] {new FunctionParameter((selectedObject.RowIndex + 1).ToString(), "number")});
    }

Then in your ASPX, you have the following function in your scripts:

<script type="text/javascript">
    
        function SelectRow(index)
        {
            var grid = ISGetObject("WebGrid1");
            grid.RootTable.GetRow(index).Select();
        }
    
</script>

Thus, everytime the button is clicked, it'll select the row from the server-side call (which seamlessly call to the client-side to do the real operation). I have also attached a working sample for your convenience.

This is a much better solution instead of refreshing the entire Grid only to perform row selection which is very costly and results in slower response.

Hope this helps,
James.
 

All times are GMT -5. The time now is 8:18 AM.
Previous Next