Update Custom Collection that is bound to DataGrid made up of Custom COlumns

Discussion in 'ASP .Net Datagrid Control' started by Terry Holland, Oct 19, 2005.

  1. 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, Oct 19, 2005
    #1
    1. Advertising

  2. 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.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
    |
    |
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 20, 2005
    #2
    1. Advertising

  3. 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.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
    > |
    > |
    > |
    > |
    > |
    >
     
    Terry Holland, Oct 20, 2005
    #3
  4. 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.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)?
    |
    | "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.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
    | > |
    | > |
    | > |
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 20, 2005
    #4
  5. 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.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)?
    > |
    > | "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.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
    > | > |
    > | > |
    > | > |
    > | > |
    > | > |
    > | >
    > |
    > |
    > |
    >
     
    Terry Holland, Oct 20, 2005
    #5
  6. 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.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
    |
    |
    | "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.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)?
    | > |
    | > | "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.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
    | > | > |
    | > | > |
    | > | > |
    | > | > |
    | > | > |
    | > | >
    | > |
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 21, 2005
    #6
  7. 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.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
    > |
    > |
    > | "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.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)?
    > | > |
    > | > | "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.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
    > | > | > |
    > | > | > |
    > | > | > |
    > | > | > |
    > | > | > |
    > | > | >
    > | > |
    > | > |
    > | > |
    > | >
    > |
    > |
    > |
    >
     
    Terry Holland, Oct 25, 2005
    #7
  8. 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.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
    |
    |
    | "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.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
    | > |
    | > |
    | > | "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.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)?
    | > | > |
    | > | > | "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.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
    | > | > | > |
    | > | > | > |
    | > | > | > |
    | > | > | > |
    | > | > | > |
    | > | > | >
    | > | > |
    | > | > |
    | > | > |
    | > | >
    | > |
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 27, 2005
    #8
  9. 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.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
    > |
    > |
    > | "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.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
    > | > |
    > | > |
    > | > | "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.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)?
    > | > | > |
    > | > | > | "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.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
    > | > | > | > |
    > | > | > | > |
    > | > | > | > |
    > | > | > | > |
    > | > | > | > |
    > | > | > | >
    > | > | > |
    > | > | > |
    > | > | > |
    > | > | >
    > | > |
    > | > |
    > | > |
    > | >
    > |
    > |
    > |
    >
     
    Terry Holland, Oct 27, 2005
    #9
  10. 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.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?
    |
    |
    |
    | "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.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
    | > |
    | > |
    | > | "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.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
    | > | > |
    | > | > |
    | > | > | "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.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)?
    | > | > | > |
    | > | > | > | "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.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
    | > | > | > | > |
    | > | > | > | > |
    | > | > | > | > |
    | > | > | > | > |
    | > | > | > | > |
    | > | > | > | >
    | > | > | > |
    | > | > | > |
    | > | > | > |
    | > | > | >
    | > | > |
    | > | > |
    | > | > |
    | > | >
    | > |
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 28, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Øyvind Isaksen
    Replies:
    1
    Views:
    1,001
    Øyvind Isaksen
    May 18, 2007
  2. Oliver Hopton

    Collection class bound to DataGrid doesn't use my custom enumerator!

    Oliver Hopton, Oct 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    135
    Alan Green
    Oct 29, 2003
  3. Sundararajan

    Implementing columns collection in datagrid custom control

    Sundararajan, Mar 25, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    119
    Sundararajan
    Mar 25, 2005
  4. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    886
    Vinki
    Apr 25, 2007
  5. Nick Bennett
    Replies:
    1
    Views:
    208
    Bob Barrows [MVP]
    Jan 20, 2008
Loading...

Share This Page