User Profile & Activity

Eric Member
Page
of 19

And any idea for a workaround for the remaining issue? I mean the problem that I now cannot hide all columns except the first one when there is no data in the resultset.

Hello Handy,

When I set the column.Visible flags in the InitializeLayout event, yes it works then. But I cannot do that.

First of all, could you please confirm that this is a bug in WebGrid 6? As far as I know the documentation does not say that I am not allowed to change the Visible column flag in the PreRender event, so it should be allowed and not crash. Either this is a documenation bug or a bug in the WebGrid then.

Regarding your workaround: The SetColumnCaptions Sub mainly changes the column titles (col.Caption). In the real project the new name depends on selections of other controls. If I put this into the InitializeLayout event, the column headers won't get updated anymore. So I separated the Sub into two different ones (SetColumnCaptions and SetColumnVisibility) and called the SetColumnCaptions from the PreRender event and SetColumnVisibility from the InitializeLayout event. In the grid_Export event I call both. This seems to work, but now I have a new problem:

When the grid is empty (no data available, depending on the other controls) then I want to display a custom message in one row telling the user that his selections didn't make sense or there is no data. In that case the InitializeDataSource event creates a New DataSet(), adds all columns necessary and adds one row containing a custom text into the first field. In PreRender I detect this special row again and if found, I increase the width of the first column and make all other columns invisible (Visible = False). This code for setting the visibility is now also in SetColumnVisibility and will not get called, resulting in showing all columns even when there is no data. I only want to show this single error message row and only one column, widened to the whole screen. How can I avoid this problem?

BTW: The refresh of the WebGrid is made this way: The other controls, that cause the content of the WebGrid to change, call their event handler (like SelectedIndexChanged). There I call grid.ClearCachedDataSource() and grid.RebindDataSource(). The WebGrid is in an UpdatePanel and has AsyncPostBackTrigger set to the get triggered from the other controls.

As you can see, I intentionally choosed the PreRender event. This worked until this problem with the crash occured.

Hmmm. It looks like something with attachments doesn't work here in the Community. It shows the same files like my initial post.

So here is the new sample again, now with different file names. Please rename them after download (remove the ".txt" and also the "2" in the name). If you don't remove the "2" in the file name you will get a wrong reference (to the first sample).

Ok, now I made a new example. It uses the 'correct' HTML 4.0 Transitional DocType and still produces the error. Actually I cannot really see any difference to my first example, but here it occurs. Please have a try at this one.

The sample indeed works when switching to DocType

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

But unfortunately the error still happens in our project, which does use this correct DocType. I will try to create another sample that uses the correct DocType and still produces this error.

Please make sure that in Internet Explorer, Internet Options, Advanced, Browsing, "Disable Script Debugging (Internet Explorer)" is NOT checked. Otherwise you won't see that it crashed. After changing this option you might have to restart IE.

Hi Handy,

First shot: Did you also try with IE6, or did you use any newer version?

Regarding DocType: This is unrelated, as in our project we use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

The other one was there, just because I created a new Visual Studio project and that is the default. BTW: WebGrid should support that also.

Regards,

Eric

I solved this myself in the meantime. It is only partially related to WebGrid.

Here's the example:

Dim ds As DataSet = ... 'data to add

Dim dt As DataTable = CType(e.DataSource, DataTable)
dt.Merge(ds.Tables(0), True, MissingSchemaAction.Error)
Posted: September 9, 2009 7:33 AM

Without telling anything about my company, I can say that in most big companies users usually don't have admin rights or are otherwise prohibited to install any software.

But thanks for letting me know the backgrounds of your decision. I can now understand this better.

I also didn't want to solve a specific problem, it was just to notify you that there actually is a problem for some users.

Posted: September 9, 2009 5:19 AM

Well, that's your free decision then. But our company with several thousand users will probably not upgrade all IE's today. And I'm sure there are still many many other IE6 users as well. But it looks like I have to live with this then...

(Did you look at the first screenshot in 1:1 resolution?)

All times are GMT -5. The time now is 9:53 AM.
Previous Next