Re: Dynamically create datagrid columns
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Sat, 08 Oct 2005 07:05:53 GMT
You're welcome Terry,
Also, as for the support call, don't worry, just tell them that you've
managed to resolve the problem yourself and ask our support guy to close it
as non-drecrement so as not to charge your incident number.
Anyway, it's my pleasure working with you. Good luck!
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
--------------------
| From: "Terry Holland" <terryeholland@xxxxxxxxxxxxxxxx>
| References: <u5WweGqwFHA.720@xxxxxxxxxxxxxxxxxxxx>
<#$sGgmrwFHA.2312@xxxxxxxxxxxxxxxxxxxx>
<2o1r7UwwFHA.2080@xxxxxxxxxxxxxxxxxxxxx>
<e640n4QxFHA.3236@xxxxxxxxxxxxxxxxxxxx>
<9wuitOYxFHA.628@xxxxxxxxxxxxxxxxxxxxx>
<#480ZmdxFHA.2880@xxxxxxxxxxxxxxxxxxxx>
<L8559b7xFHA.780@xxxxxxxxxxxxxxxxxxxxx>
<u5p3WfAyFHA.700@xxxxxxxxxxxxxxxxxxxx>
<wUer1oCyFHA.2624@xxxxxxxxxxxxxxxxxxxxx>
<#At4PXDyFHA.3892@xxxxxxxxxxxxxxxxxxxx>
<aUA2ZNLyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
<eO2F41SyFHA.2800@xxxxxxxxxxxxxxxxxxxx>
<6klTsrUyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
<eiSHLBnyFHA.156@xxxxxxxxxxxxxxxxxxxx>
<mofIEJwyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| Subject: Re: Dynamically create datagrid columns
| Date: Fri, 7 Oct 2005 10:30:06 +0100
| Lines: 291
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <eeYk2GyyFHA.4032@xxxxxxxxxxxxxxxxxxxx>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: host31.multiserv.com 194.200.135.31
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5738
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| Eureka! This code works!
|
| Steven, thanks for your efforts. I think the lesson to be learnt from
this
| is "I should post my code so that you can see what Im trying"
|
| Thanks again (looks like I wasted a support call :-( )
|
| "Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
| news:mofIEJwyFHA.768@xxxxxxxxxxxxxxxxxxxxxxxx
| > Hi Terry,
| >
| > Thanks for your code sample. I think I've got the answer for this
problem.
| > In fact, I should have noticed this earlier, the problem is still in the
| > Custom DataGrid Column. In the Cell_DataBinding function, we use the
| > following VB.NET code:
| > ================
| > Private Sub Cell_DataBinding(ByVal sender As Object, ByVal e As
| EventArgs)
| > Dim cell As TableCell = sender
| > Dim item As DataGridItem = cell.NamingContainer
| > Dim txt As TextBox = item.FindControl(m_strID)
| >
| > 'Try
| > Dim obj1 As Object = item.DataItem(m_strDataField)
| >
| >
| > txt.Text = CType(obj1, String)
| > 'Catch ex As Exception
| > ' Throw New Exception("Invalid DataField for
SCTextBoxColumnNot
| > ")
| > 'End Try
| > End Sub
| > ====================
| >
| > Notice this line :
| >
| > Dim obj1 As Object = item.DataItem(m_strDataField)
| >
| > since VB.NET bydefault support late binding, so we can use DataItem( ..)
| > without casting it to the DataRowView first. And this only works when
the
| > DataSouce is DataSet/DataTable since it will generate DataView for the
| > final datasource. However, when you use custom collection class, we
need
| > to access the property explicitly like
| >
| > obj.PropertyName rather than obj("propertyname")
| >
| > that's why our original code failed. In fact, my C# example, did use
the
| > PropertyDescriptor to dynamically query the property value, so we just
| need
| > to change the above VBNET code to the below one:
| >
| >
| > Dim pd As PropertyDescriptor =
| > TypeDescriptor.GetProperties(item.DataItem).Find(m_strDataField, True)
| >
| > Dim obj1 As Object = pd.GetValue(item.DataItem)
| >
| >
| > I've tested on my side on the page which use your custom collection as
| > DataSource.
| >
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| >
| >
| > --------------------
| > | From: "Terry Holland" <terryeholland@xxxxxxxxxxxxxxxx>
| > | References: <u5WweGqwFHA.720@xxxxxxxxxxxxxxxxxxxx>
| > <#$sGgmrwFHA.2312@xxxxxxxxxxxxxxxxxxxx>
| > <2o1r7UwwFHA.2080@xxxxxxxxxxxxxxxxxxxxx>
| > <e640n4QxFHA.3236@xxxxxxxxxxxxxxxxxxxx>
| > <9wuitOYxFHA.628@xxxxxxxxxxxxxxxxxxxxx>
| > <#480ZmdxFHA.2880@xxxxxxxxxxxxxxxxxxxx>
| > <L8559b7xFHA.780@xxxxxxxxxxxxxxxxxxxxx>
| > <u5p3WfAyFHA.700@xxxxxxxxxxxxxxxxxxxx>
| > <wUer1oCyFHA.2624@xxxxxxxxxxxxxxxxxxxxx>
| > <#At4PXDyFHA.3892@xxxxxxxxxxxxxxxxxxxx>
| > <aUA2ZNLyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| > <eO2F41SyFHA.2800@xxxxxxxxxxxxxxxxxxxx>
| > <6klTsrUyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| > | Subject: Re: Dynamically create datagrid columns
| > | Date: Thu, 6 Oct 2005 13:20:06 +0100
| > | Lines: 440
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| > | Message-ID: <eiSHLBnyFHA.156@xxxxxxxxxxxxxxxxxxxx>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: host31.multiserv.com 194.200.135.31
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5726
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | Steven
| > |
| > | Thank you for your assistance. I am still having problems so I have
| > opened
| > | a support ticket. This is the email that I have sent with an
attachment
| > | that contains code that highlights my problem. Maybe you could solve
| this
| > | using my code.
| > |
| > | Terry Holland
| > |
| > |
| > | Dear Mr. Holland,
| > |
| > | Thank you for calling Microsoft?Developer Support in reference to your
| > | development issue. In order to help me route your case to a suitably
| > | qualified engineer, could you please provide the following
information:
| > |
| > | 1. Development Product and service pack(s) being used.
| > |
| > | Visual Studio.Net, ASP.Net, VB.Net
| > |
| > | 2. Operating System(s) and service pack(s) on which the
problem
| > | occurs (client, server?).
| > |
| > | XP pro sp2
| > |
| > | 3. .Net framework version and service pack(s)(if relevant).
| > |
| > | not sure
| > |
| > | 4. Database version(s) and service pack(s)and technology
used(if
| > | relevant).
| > |
| > | na
| > |
| > | 5. A detailed description of the problem.
| > |
| > | I have been getting assistance from the following on this matter:
| > |
| > | Support Person: Steven Cheng[MSFT] <stcheng@xxxxxxxxxxxxxxxxxxxx>
| > | Newsgroup: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | Post Title: Dynamically create datagrid columns
| > |
| > | Basically I am trying to create a web user control that is basically a
| > | datagrid. The datagrid will contain columns that are a collection of
| > | dynamically created custom columns. The data will come from a custom
| > | collection.
| > | In my attempts to get this to work I have tried a number of things and
| had
| > | some useful help from Setven Cheng but I still get the error
| > | "System.MissingMemberException: No Default member found for type Test"
| > when
| > | I try to DataBind.
| > |
| > | In the attached zip I have provided some test code to highlight the
| > problem.
| > | I have not used a web user control in this test because the error
occurs
| > | whether I use web user control or not. It seems to be a data binding
| > | problem
| > |
| > | Explanation of code
| > |
| > | DataSources.vb
| > | This contains my custom collection and the class that this collection
is
| a
| > | collection of
| > |
| > | clsDGCTB.vb
| > | This contains my test custom column. Code is pretty much as provided
by
| > | Steven Cheng.
| > |
| > | TestCustomCollection.aspx & code behind page
| > | This page attempts to add 2 of my custom columns and then bind to my
| > custom
| > | collection.
| > | This produces the error when I attempt to to databind
| > |
| > | TestBoundColumns.aspx and code behind page
| > | This page adds 2 BoundColumns to datagrid and then binds to my custom
| > | collection.
| > | This works without error.
| > |
| > | TestDataTable.aspx & code behind page
| > | This page adds 2 custom columns to datagrid and then binds to a
| DataTable.
| > | This works without error.
| > |
| > | So from the above we can see that my Custom Columns (clsDGCTB) work
if I
| > | bind to a DataTable but not to my CustomCollection
| > | and my CustomCollection works if I dynamically add BoundColumns to
| > datagrid
| > |
| > | WHat I need is for my CustomCollection to be able to bind to a grid
made
| > up
| > | of my custom columns.
| > | 6. Any error messages that you may be receiving (if
relevant).
| > |
| > | System.MissingMemberException: No Default member found for type Test
| > |
| > | 7. Any source code that reproduces the problem (if
relevant).
| > |
| > | See Zip
| > |
| > | 8. Details of workarounds attempted and there results (if
| > | relevant).
| > |
| > | 9. Details of any online Microsoft Knowledge Base articles
| used
| > | (if relevant).
| > |
| > |
| > |
| >
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
| > /creatingcustomcolumns.asp
| > |
| > | 10. Details of any Virus Checkers Installed.
| > |
| > | McAfee VirusScan Enterprise 8.0
| > |
| > | 11. Given the issue discussed above what would you consider a
| > | satisfactory resolution to this case?
| > |
| > | To be able to bind my custom collection to my datagrid that is made
up
| > of
| > | a number of custom columns
| > |
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
| > | news:6klTsrUyFHA.768@xxxxxxxxxxxxxxxxxxxxxxxx
| > | > Oh, what's a silly mistake, I attached the wrong files. Here is the
| > VB.NET
| > | > files.
| > | > Sorry for the inconvenience.
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | > --------------------
| > | > | From: "Terry Holland" <terryeholland@xxxxxxxxxxxxxxxx>
| > | > | References: <u5WweGqwFHA.720@xxxxxxxxxxxxxxxxxxxx>
| > | > <#$sGgmrwFHA.2312@xxxxxxxxxxxxxxxxxxxx>
| > | > <2o1r7UwwFHA.2080@xxxxxxxxxxxxxxxxxxxxx>
| > | > <e640n4QxFHA.3236@xxxxxxxxxxxxxxxxxxxx>
| > | > <9wuitOYxFHA.628@xxxxxxxxxxxxxxxxxxxxx>
| > | > <#480ZmdxFHA.2880@xxxxxxxxxxxxxxxxxxxx>
| > | > <L8559b7xFHA.780@xxxxxxxxxxxxxxxxxxxxx>
| > | > <u5p3WfAyFHA.700@xxxxxxxxxxxxxxxxxxxx>
| > | > <wUer1oCyFHA.2624@xxxxxxxxxxxxxxxxxxxxx>
| > | > <#At4PXDyFHA.3892@xxxxxxxxxxxxxxxxxxxx>
| > | > <aUA2ZNLyFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| > | > | Subject: Re: Dynamically create datagrid columns
| > | > | Date: Tue, 4 Oct 2005 22:49:13 +0100
| > | > | Lines: 5
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <eO2F41SyFHA.2800@xxxxxxxxxxxxxxxxxxxx>
| > | > | Newsgroups:
microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | NNTP-Posting-Host: 82.152.27.185
| > | > | Path:
| TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5707
| > | > | X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > |
| > | > | Steven
| > | > |
| > | > | The attachment is still C#
| > | > |
| > | > |
| > | > |
| > |
| > |
| > |
| >
|
|
|
.
- References:
- Re: Dynamically create datagrid columns
- From: Steven Cheng[MSFT]
- Re: Dynamically create datagrid columns
- From: Terry Holland
- Re: Dynamically create datagrid columns
- From: Terry Holland
- Re: Dynamically create datagrid columns
- From: Terry Holland
- Re: Dynamically create datagrid columns
- From: Steven Cheng[MSFT]
- Re: Dynamically create datagrid columns
- From: Terry Holland
- Re: Dynamically create datagrid columns
- Prev by Date: Re: DataGrid Not Sorting
- Next by Date: Unable to get selected values from dropdownlist, present in DataGrid.
- Previous by thread: Re: Dynamically create datagrid columns
- Next by thread: How to custom gridview control if it derive from web user control?
- Index(es):
Relevant Pages
|