| Home | Forums | Reviews | Guides | Newsgroups | Register | Search |
![]() |
| Thread Tools |
| Terry Holland |
|
|
|
| |
|
Steven Cheng[MSFT]
Guest
Posts: n/a
|
Hello again Terry,
First, glad that you've been working well with the custom columns 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" <> | 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: <> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | | 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 | | | | | |
|
|
|
|
|||
|
|||
| Steven Cheng[MSFT] |
|
|
|
| |
|
Terry Holland
Guest
Posts: n/a
|
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)? "Steven Cheng[MSFT]" <> wrote in message news:... > Hello again Terry, > > First, glad that you've been working well with the custom columns > 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" <> > | 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: <> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | Xref: TK2MSFTNGXA01.phx.gbl > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | 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 > | > | > | > | > | > |
|
|
|
|
|||
|
|||
| Terry Holland |
|
Steven Cheng[MSFT]
Guest
Posts: n/a
|
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" <> | References: <> <> | 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: <#> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | | 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)? | | "Steven Cheng[MSFT]" <> wrote in message | news:... | > 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" <> | > | 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: <> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | Xref: TK2MSFTNGXA01.phx.gbl | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | | > | 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 | > | | > | | > | | > | | > | | > | | | |
|
|
|
|
|||
|
|||
| Steven Cheng[MSFT] |
|
Terry Holland
Guest
Posts: n/a
|
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 "Steven Cheng[MSFT]" <> wrote in message news:... > 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" <> > | References: <> > <> > | 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: <#> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl > | Xref: TK2MSFTNGXA01.phx.gbl > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | 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)? > | > | "Steven Cheng[MSFT]" <> wrote in message > | news:... > | > 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" <> > | > | 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: <> > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | 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 > | > | > | > | > | > | > | > | > | > | > | > > | > | > | > |
|
|
|
|
|||
|
|||
| Terry Holland |
|
Steven Cheng[MSFT]
Guest
Posts: n/a
|
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" <> | References: <> <> <#> <> | 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: <> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5834 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | | 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 | | | "Steven Cheng[MSFT]" <> wrote in message | news:... | > 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" <> | > | References: <> | > <> | > | 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: <#> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl | > | Xref: TK2MSFTNGXA01.phx.gbl | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | | > | 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)? | > | | > | "Steven Cheng[MSFT]" <> wrote in message | > | news:... | > | > 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" <> | > | > | 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: <> | > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 | > | > | Path: | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 | > | > | X-Tomcat-NG: | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | | > | > | 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 | > | > | | > | > | | > | > | | > | > | | > | > | | > | > | > | | > | | > | | > | | | |
|
|
|
|
|||
|
|||
| Steven Cheng[MSFT] |
|
Terry Holland
Guest
Posts: n/a
|
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 "Steven Cheng[MSFT]" <> wrote in message news:... > 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" <> > | References: <> > <> > <#> > <> > | 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: <> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | Xref: TK2MSFTNGXA01.phx.gbl > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5834 > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | 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 > | > | > | "Steven Cheng[MSFT]" <> wrote in message > | news:... > | > 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" <> > | > | References: <> > | > <> > | > | 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: <#> > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | 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)? > | > | > | > | "Steven Cheng[MSFT]" <> wrote in message > | > | news:... > | > | > 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" <> > | > | > | 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: <> > | > | > | Newsgroups: > microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 > | > | > | Path: > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 > | > | > | X-Tomcat-NG: > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | > | > | 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 > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > > | > | > | > | > | > | > | > > | > | > | > |
|
|
|
|
|||
|
|||
| Terry Holland |
|
Steven Cheng[MSFT]
Guest
Posts: n/a
|
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" <> | References: <> <> <#> <> <> <> | 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: <> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | NNTP-Posting-Host: host89.multiserv.com 194.200.135.89 | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5857 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | | 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 | | | "Steven Cheng[MSFT]" <> wrote in message | news:... | > 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" <> | > | References: <> | > <> | > <#> | > <> | > | 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: <> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | Xref: TK2MSFTNGXA01.phx.gbl | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5834 | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | | > | 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 | > | | > | | > | "Steven Cheng[MSFT]" <> wrote in message | > | news:... | > | > 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" <> | > | > | References: <> | > | > <> | > | > | 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: <#> | > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | > | > | Path: | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 | > | > | X-Tomcat-NG: | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | | > | > | 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)? | > | > | | > | > | "Steven Cheng[MSFT]" <> wrote in message | > | > | news:... | > | > | > 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" <> | > | > | > | 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: <> | > | > | > | Newsgroups: | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 | > | > | > | Path: | > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 | > | > | > | X-Tomcat-NG: | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | | > | > | > | 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 | > | > | > | | > | > | > | | > | > | > | | > | > | > | | > | > | > | | > | > | > | > | > | | > | > | | > | > | | > | > | > | | > | | > | | > | | | |
|
|
|
|
|||
|
|||
| Steven Cheng[MSFT] |
|
Terry Holland
Guest
Posts: n/a
|
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? "Steven Cheng[MSFT]" <> wrote in message news:rN8y$... > 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" <> > | References: <> > <> > <#> > <> > <> > <> > | 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: <> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | NNTP-Posting-Host: host89.multiserv.com 194.200.135.89 > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl > | Xref: TK2MSFTNGXA01.phx.gbl > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5857 > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | 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 > | > | > | "Steven Cheng[MSFT]" <> wrote in message > | news:... > | > 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" <> > | > | References: <> > | > <> > | > <#> > | > <> > | > | 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: <> > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5834 > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | 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 > | > | > | > | > | > | "Steven Cheng[MSFT]" <> wrote in message > | > | news:... > | > | > 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" <> > | > | > | References: <> > | > | > <> > | > | > | 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: <#> > | > | > | Newsgroups: > microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 > | > | > | Path: > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl > | > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 > | > | > | X-Tomcat-NG: > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | > | > | 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)? > | > | > | > | > | > | "Steven Cheng[MSFT]" <> wrote in > message > | > | > | news:... > | > | > | > 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" <> > | > | > | > | 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: <> > | > | > | > | Newsgroups: > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 > | > | > | > | Path: > | > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl > | > | > | > | Xref: TK2MSFTNGXA01.phx.gbl > | > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 > | > | > | > | X-Tomcat-NG: > | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol > | > | > | > | > | > | > | > | 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 > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > > | > | > | > | > | > | > | > | > | > | > | > > | > | > | > | > | > | > | > > | > | > | > |
|
|
|
|
|||
|
|||
| Terry Holland |
|
Steven Cheng[MSFT]
Guest
Posts: n/a
|
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" <> | References: <> <> <#> <> <> <> <> <rN8y$> | 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: <> | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | NNTP-Posting-Host: host69.multiserv.com 194.200.135.69 | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5880 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | | 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? | | | | "Steven Cheng[MSFT]" <> wrote in message | news:rN8y$... | > 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" <> | > | References: <> | > <> | > <#> | > <> | > <> | > <> | > | 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: <> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | NNTP-Posting-Host: host89.multiserv.com 194.200.135.89 | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl | > | Xref: TK2MSFTNGXA01.phx.gbl | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5857 | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | | > | 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 | > | | > | | > | "Steven Cheng[MSFT]" <> wrote in message | > | news:... | > | > 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" <> | > | > | References: <> | > | > <> | > | > <#> | > | > <> | > | > | 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: <> | > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | > | > | Path: | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5834 | > | > | X-Tomcat-NG: | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | | > | > | 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 | > | > | | > | > | | > | > | "Steven Cheng[MSFT]" <> wrote in message | > | > | news:... | > | > | > 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" <> | > | > | > | References: <> | > | > | > <> | > | > | > | 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: <#> | > | > | > | Newsgroups: | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | NNTP-Posting-Host: host240.multiserv.com 194.200.135.240 | > | > | > | Path: | > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl | > | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5830 | > | > | > | X-Tomcat-NG: | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | | > | > | > | 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)? | > | > | > | | > | > | > | "Steven Cheng[MSFT]" <> wrote in | > message | > | > | > | news:... | > | > | > | > 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" <> | > | > | > | > | 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: <> | > | > | > | > | Newsgroups: | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | > | NNTP-Posting-Host: host158.multiserv.com 194.200.135.158 | > | > | > | > | Path: | > | > | TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl | > | > | > | > | Xref: TK2MSFTNGXA01.phx.gbl | > | > | > | > microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5824 | > | > | > | > | X-Tomcat-NG: | > | > | microsoft.public.dotnet.framework.aspnet.datagridc ontrol | > | > | > | > | | > | > | > | > | 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 | > | > | > | > | | > | > | > | > | | > | > | > | > | | > | > | > | > | | > | > | > | > | | > | > | > | > | > | > | > | | > | > | > | | > | > | > | | > | > | > | > | > | | > | > | | > | > | | > | > | > | | > | | > | | > | | | |
|
|
|
|
|||
|
|||
| Steven Cheng[MSFT] |
|
|
|
| |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in running a basic code in python 3.3.0 that includes HTML file | Satabdi Mukherjee | Python | 1 | 04-04-2013 07:48 PM |
| Collection problems (create Collection object, add data to collection, bind collection to datagrid) | Øyvind Isaksen | ASP .Net | 1 | 05-18-2007 09:24 AM |
| template columns and bound columns in gridview | Vinki | ASP .Net Web Controls | 2 | 04-25-2007 04:22 PM |
| Implementing columns collection in datagrid custom control | Sundararajan | ASP .Net Web Controls | 0 | 03-25-2005 08:51 AM |
| Collection class bound to DataGrid doesn't use my custom enumerator! | Oliver Hopton | ASP .Net Datagrid Control | 1 | 10-29-2003 10:22 PM |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc..
SEO by vBSEO ©2010, Crawlability, Inc. |




