Hi Terry,
I've added some additional code to the custom column example I've sent you
previously. I add some simple clientscript in the CustomTextBoxColumn's
render code so as to let the clientscript check the textbox's value when
user changed and left the textbox at clientside. You can start customizing
it with your own script. I've attached the files in this message.
Hope helps. 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" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<#
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: Re: Update Custom Collection that is bound to DataGrid made up
of Custom COlumns
| Date: Thu, 27 Oct 2005 13:01:39 +0100
| Lines: 396
| 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: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: host69.multiserv.com 194.200.135.69
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5880
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| I think I will be able to get my head around the Javascript but Im not
sure
| where to start in tying it all together. How would I link my custom
column
| to the Javascript? Where would I write the Javascript?
|
|
|
| | > Hi Terry,
| >
| > AS for numberic formatting script, I'm also not very experienced on
this.
| > However, I've used to get some similiar resources on the web, here are
| some
| > good articles:
| >
| >
http://www.mredkj.com/javascript/numberFormat.html
| >
| >
http://www.eggheadcafe.com/articles/20031204.asp
| >
| > You can leverage your own one from those ones.
| > Hope helps. 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" <
[email protected]>
| > | References: <
[email protected]>
| > <
[email protected]>
| > <#
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > | Subject: Re: Update Custom Collection that is bound to DataGrid made
up
| > of Custom COlumns
| > | Date: Tue, 25 Oct 2005 13:23:31 +0100
| > | Lines: 299
| > | 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: <
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: host89.multiserv.com 194.200.135.89
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5857
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | I am totally unfamiliar with client-side coding. Could you give me an
| > | example of how to format one of my custom columns as 2 decimal places
| > |
| > | tia
| > |
| > | Terry Holland
| > |
| > |
| > | | > | > Hi Terry,
| > | >
| > | > You can set the TextBox as AutoPostBack and use serverside
codebehind
| > code
| > | > to format the user's inputs, however as you also mentioned, this
will
| > | > involve too much postback. So I would prefer to using clientside
| script
| > to
| > | > do the formatting as much as possible though it'll be abit more
| complex
| > | > than serverside code.
| > | >
| > | > 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" <
[email protected]>
| > | > | References: <
[email protected]>
| > | > <
[email protected]>
| > | > <#
[email protected]>
| > | > <
[email protected]>
| > | > | Subject: Re: Update Custom Collection that is bound to DataGrid
made
| > up
| > | > of Custom COlumns
| > | > | Date: Thu, 20 Oct 2005 16:05:12 +0100
| > | > | Lines: 210
| > | > | 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: <
[email protected]>
| > | > | Newsgroups:
microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240
| > | > | Path:
| TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5834
| > | > | X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > |
| > | > | OK thanks
| > | > |
| > | > | One other point. How would you suggest that I accomplish this
| > | requirement
| > | > | (though I my not bother if it involves many postbacks)?
| > | > | One of the properties of my custom columns is NumberFormat. If
this
| > is
| > | > set
| > | > | to Currency, the data that is displayed will be format in local
| > | currency.
| > | > | If however the user modifies a currency value, could I get the
| column
| > to
| > | > | format number as user leaves cell ie as it would happen in Excel?
| > | > |
| > | > | Terry Holland
| > | > |
| > | > |
message
| > | > | | > | > | > Hi Terry,
| > | > | >
| > | > | > As for accessing properties in custom object. Yes, you can use
| .net
| > 's
| > | > | > reflection api to dynamically access property through a string
| > | > | > value(contains the property's name), and we can provide a
certain
| > | > property
| > | > | > or field in custom column to hold such a string value. But IMO,
I
| > | don't
| > | > | > suggest this since reflection will have performance hurt on our
| > | > | > application. So if possible, you'd better create some hardcoded
| > | > funcdtions
| > | > | > in page which do the update operations(retrieve value from
| > | datagriditem
| > | > | and
| > | > | > update the specific properteis in custom object.
| > | > | >
| > | > | > 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" <
[email protected]>
| > | > | > | References: <
[email protected]>
| > | > | > <
[email protected]>
| > | > | > | Subject: Re: Update Custom Collection that is bound to
DataGrid
| > made
| > | > up
| > | > | > of Custom COlumns
| > | > | > | Date: Thu, 20 Oct 2005 10:18:03 +0100
| > | > | > | Lines: 125
| > | > | > | 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: <#
[email protected]>
| > | > | > | Newsgroups:
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240
| > | > | > | Path:
| > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5830
| > | > | > | X-Tomcat-NG:
| > | microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | > |
| > | > | > | Would I then need to look into reflection to find the property
| in
| > my
| > | > | > custom
| > | > | > | class that I need to update (via the custom column DataField
| > | > property)?
| > | > | > |
| > message
| > | > | > | | > | > | > | > Hello again Terry,
| > | > | > | >
| > | > | > | > First, glad that you've been working well with the custom
| > columns
| > | >
.
| > | > | > As
| > | > | > | > for the generic way for updating custom collections from the
| > | > datalist,
| > | > | I
| > | > | > | > think we still need to manually loop through all the
| > DataGridItems
| > | > in
| > | > | > | > datagrid and then find the certain control instance of each
| > column
| > | > and
| > | > | > | > query the certain property(Text ...) from the control.
Also,
| as
| > | > | > mentioned
| > | > | > | > in my former custom column example, we can specify a
| > "TextBoxID"
| > | or
| > | > | > more
| > | > | > | > commonly a "ControlID" property for our custom column so as
to
| > | > easily
| > | > | > find
| > | > | > | > the control in template through DataGridItem's FindControl
| > | method.
| > | > | In
| > | > | > | > additino, we can event encapsulate the dataretrieving method
| in
| > | the
| > | > | > | Custtom
| > | > | > | > Column class, for example, for our CustomColumn class, we
can
| > | > provide
| > | > | a
| > | > | > | > method like below:
| > | > | > | >
| > | > | > | > public class CustomTextBoxColumn
| > | > | > | > {
| > | > | > | > public string txtID;
| > | > | > | >
| > | > | > | > public string GetColumnValue(DataGridItem item)
| > | > | > | > {
| > | > | > | > TextBox txt = item.FindControl(txtID);
| > | > | > | > return txt.Text;
| > | > | > | > }
| > | > | > | >
| > | > | > | > }
| > | > | > | >
| > | > | > | > Hope helps. 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" <
[email protected]>
| > | > | > | > | Subject: Update Custom Collection that is bound to
DataGrid
| > made
| > | > up
| > | > | of
| > | > | > | > Custom COlumns
| > | > | > | > | Date: Wed, 19 Oct 2005 17:01:47 +0100
| > | > | > | > | Lines: 51
| > | > | > | > | X-Priority: 3
| > | > | > | > | X-MSMail-Priority: Normal
| > | > | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| > | > | > | > | X-RFC2646: Format=Flowed; Original
| > | > | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| > | > | > | > | Message-ID: <
[email protected]>
| > | > | > | > | Newsgroups:
| > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158
| > | > | > | > | Path:
| > | > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > | > | >
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5824
| > | > | > | > | X-Tomcat-NG:
| > | > | microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | > | > |
| > | > | > | > | I recieved some very useful help from Steven Cheng in an
| > earlier
| > | > | post
| > | > | > in
| > | > | > | > | this group entitled 'Dynamically create datagrid columns'
| and
| > | am
| > | > | now
| > | > | > | > | looking for some help to progress things.
| > | > | > | > |
| > | > | > | > | With the help I was given I was able to create a web user
| > | control
| > | > | that
| > | > | > | > | dynamically created a datagrid that was made up a number
of
| > | custom
| > | > | > | > datagrid
| > | > | > | > | columns. I am able to bind a custom collection to this
| > datagrid
| > | > and
| > | > | I
| > | > | > | am
| > | > | > | > | able to view my data.
| > | > | > | > | Some of the custom columns are editable columns
containing a
| > | > control
| > | > | > | such
| > | > | > | > as
| > | > | > | > | Textbox, DropDown List, Checkbox etc.
| > | > | > | > | What I would like to do is, on the click of a button, set
| the
| > | > value
| > | > | in
| > | > | > | my
| > | > | > | > | custom object (the object that my custom collection is a
| > | > collection
| > | > | > of)
| > | > | > | > to
| > | > | > | > | be equal to the corresponding value in the datagrid
column.
| ie
| > | > | > | > | I have a class called clsStock and a collection of
clsStock
| > | > objects
| > | > | > | > called
| > | > | > | > | clsStock_COL. In my clsStock class I have the following
| > | > properties
| > | > | > | > | ID
| > | > | > | > | DESCRIPTION
| > | > | > | > | COSTPRICE
| > | > | > | > | SALEPRICE
| > | > | > | > | WHR
| > | > | > | > | SUPPLIER
| > | > | > | > |
| > | > | > | > | I wish to display the following properties in my control
| > | > | > | > |
| > | > | > | > | ID displayed in CUSTOMCOLUMN_Label (column0)
| > | > | > | > | DESCRIPTION displayed in CUSTOMCOLUMN_Label (column1)
| > | > | > | > | COSTPRICE displayed in CUSTOMCOLUMN_Label (column2)
| > | > | > | > | SALEPRICE displayed in CUSTOMCOLUMN_TextBox (column3)
| > | > | > | > | WHR displayed in CUSTOMCOLUMN_TextBox (column4)
| > | > | > | > |
| > | > | > | > | When the user clicks update button I want to update my
| object
| > of
| > | > | type
| > | > | > | > | clsStock so that
| > | > | > | > | SALEPRICE = value displayed in CUSTOMCOLUMN_TextBox
| (column3)
| > | > | > | > | WHR =value displayed in CUSTOMCOLUMN_TextBox (column4)
| > | > | > | > |
| > | > | > | > | In another application of this control it may be the case
| that
| > | > | > clsOrder
| > | > | > | &
| > | > | > | > | clsOrder_COL are the classes that bind to my datagrid and
| > when I
| > | > | click
| > | > | > | > | update, the value in column3 may update the QUANTITY
| property
| > | of
| > | > my
| > | > | > | > | clsOrder class and column7 may update property DISCOUNT of
| my
| > | > | clsOrder
| > | > | > | > | class.
| > | > | > | > |
| > | > | > | > | So I am looking for an example of a generic way of
updating
| my
| > | > | custom
| > | > | > | > | collections from my (datagrid) control.
| > | > | > | > |
| > | > | > | > | tia
| > | > | > | > |
| > | > | > | > | Terry Holland
| > | > | > | > |
| > | > | > | > |
| > | > | > | > |
| > | > | > | > |
| > | > | > | > |
| > | > | > | >
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|