This is a migrated thread and some comments may be shown as answers.

[Solved] How to capture RadCombo Decimal Type Selected Items from Multicolumn RadCombo in Rad Grid RadGrid1_UpdateCommand Event..

4 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 19 Jan 2010, 08:58 PM
Folks,

I am using RadControls for ASP.NET AJAX Q2 2009 SP1 with Visual Studio 2008 SP1, IE7 and WinXP SP3. 

I am using Form Template. I have a Rad Combo Box Template Column name Budget that is Decimal Type. My question is that how do I capture the value of that Template column in RadGrid1_UpdateCommand?  Basically In RadGrid1_UpdateCommand, I want to store the Value of Template Column Budget into SqlDataSource4.UpdateParameters["Budget "].DefaultValue .

I know how to capture the Template value if it is string type based on below post from Shinu. But I am having some difficulty to retrieve the Decimal Data Type Value. 


Shinu's Post:

http://www.telerik.com/community/forums/aspnet-ajax/combobox/how-to-capture-radcombo-selected-items-from-multicolumn-radcombo.aspx

Below is my code. Any help will be appreciated. Thanks..

GC_0620

 <DetailTables> 
<telerik:GridTableView runat="server" DataSourceID="SqlDataSource4" DataKeyNames="JobPersonID"   
            ShowHeader ="true" Width="100%"  CommandItemDisplay"TopAndBottom" Name = "Detail"       
            AllowAutomaticDeletes="true" AllowAutomaticInserts="true" onupdatecommand="RadGrid1_UpdateCommand"    
            AllowAutomaticUpdates="true" BorderColor="#BC9A10" GridLines="None">  
                <ParentTableRelation>   
                <telerik:GridRelationFields DetailKeyField="PersonId" MasterKeyField="PersonTableID" /> 
                     
                 </ParentTableRelation> 
                   
            <RowIndicatorColumn> 
      
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn > 
                <HeaderStyle Width="20px" ForeColor="Aqua" /> 
            </ExpandCollapseColumn> 
              
 
            <Columns> 
             
            ''''  
        <telerik:GridBoundColumn DataField="PositionControlNum" HeaderText="Position Control#" HeaderStyle-Width="50%"   
            SortExpression="PositionControlNum" UniqueName="PositionControlNum" > 
<HeaderStyle Width="50%"></HeaderStyle> 
        </telerik:GridBoundColumn> 
        ''''  
              
               
    </Columns> 
      
   <EditFormSettings EditFormType="Template">  
<EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
    <FormTemplate> 
    <table id="Table1a" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" 
                            style="border-collapse: collapse; background: white;">  
                            <tr class="EditFormHeader">  
                                <td colspan="2">  
                                <asp:Label ID="UserJobLabel"   
                                CssClass="form-local_Headers"  runat="server" Text="User Job Details"   
                                                      
        Font-Underline="True"    
               ></asp:Label>    
                                  </td> 
                            </tr> 
                           <tr> 
                           
                                <td> 
                                </td> 
                                <tr> 
                                    <td> 
                                                Position Control#</td> 
                                              
                                    <td> 
                                           <telerik:RadComboBox ID="RadComboBoxPositionControl" runat="server"   
                                            DataSourceID="SqlDataSource5" DataTextField="PositionControlNum" DataValueField="PositionControlNum"   
                                            DropDownWidth="599px" Height="110px" HighlightTemplatedItems="true"   
                                            MarkFirstMatch="true"   
                                           SelectedValue='<%#Bind("PositionControlNum") %>' Width="600px"   
                                              
                                            > 
                                            <HeaderTemplate> 
                                                <table cellpadding="0" cellspacing="0" style="width: 565px">  
                                                    <tr> 
                                                        <td style="width: 105px;">  
                                                            Position Control#</td> 
                                                         
                                      
                                            <td style="width: 75px;">  
                                                            Budget</td> 
                                                            ''  
                                                            ''      
                                                          
                                                    </tr> 
                                                </table> 
                                            </HeaderTemplate> 
                                            <ItemTemplate> 
                                                <table cellpadding="0" cellspacing="0" style="width: 565px">  
                                                    <tr> 
                                                      <td style="width: 105px;">  
 
                                                          <%# DataBinder.Eval(Container.DataItem, "PositionControlNum") %> 
                                                       </td> 
                                                      
                                                       <td style="width: 75px;">  
                                                       <%# DataBinder.Eval(Container.DataItem, "Budget", "{0:N2}")%> 
                                                           </td>   
                                                        ''  
                                                        ''  
                                                    </tr> 
                                                </table> 
                                            </ItemTemplate> 
                                                                                       
                                        </telerik:RadComboBox> 
                                         
                                    </td> 
                                  
                                      
                                                                      
                                                                          
                                <tr> 
                                    <td> 
                                    </td> 
                                    <td> 
                                    <asp:Label ID = "FormTemplate_Label" runat = "server"></asp:Label> 
                                    </td> 
                                    <td> 
                                     
                                    </td> 
                                    <td align="right" colspan="2">  
                                        <asp:Button ID="btnUpdate" runat="server" CssClass="form-button"   
                                            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'   
                                            Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'   
                                           /> 
                                        &nbsp;  
                                        <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CssClass="form-button"   
                                            CommandName="Cancel" Text="Cancel" /> 
                                    </td> 
                                </tr> 
                           
                           </tr> 
                        </table> 
      
    </FormTemplate> 
    </EditFormSettings> 
      
        </telerik:GridTableView> 
 <DetailTables> 
 
''''  
 
<asp:SqlDataSource ID="SqlDataSource4" runat="server"   
           ConnectionString="<%$ ConnectionStrings:My_AuthorizationConnectionString %>"   
             
           SelectCommand=" ...." 
           DeleteCommand="..."   
           InsertCommand="..." 
             
           UpdateCommand="..." 
            <UpdateParameters> 
              
                <asp:Parameter Name="PositionControlNum" Type="String" /> 
                <asp:Parameter Name="Budget" Type="Decimal" /> 
                ''''  
            </UpdateParameters> 
            <InsertParameters> 
        ''''  
              
            </InsertParameters> 
       </asp:SqlDataSource> 

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 22 Jan 2010, 09:24 AM
Hello,

If none of the standard methods for fetching the data which the user entered/selected is suitable in your scenario, you can use the Update command event handler of the grid, to get a reference to the controls in the edit form. Additional information on this is available in the following article:

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

I hope this information gets you started properly.

Kind regards,

Yavor
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
gc_0620
Top achievements
Rank 1
answered on 25 Jan 2010, 09:25 PM

Yavor 
I think you misunderstood me.  I need to capture the $ Amount from selected RadCombobox row and pass it to RadGrid Update Event. Not a problem if it is string  data type but having some problem with sql money data type...

Let me simplify:

Below is how the data displaying in my RadComboBox:  RadComboBoxPositionControl

PositionControlNum                                Budget
111                                                         209.89
222                                                        123.88
''
''

No problem at all to pull the Data  into RadComboBox. 
__________

Below is my sql  2005 Table Structure (Table Name: JobPerson)  

JobPersonID                               int                --- This is auto number primary key
PositionControlNum                    nvarchar(100)
Budget                                        money
'''
''
I am pulling/updating my GridTableView  from this Table (i.e. via DataSourceID="SqlDataSource4") 

Below is my Update command, need help in assigning SqlDataSource4.UpdateParameters["Budget "].DefaultValue..

For example if I select  PositionControNum: 111 and Budget:  209.89 (i.e. the 1st row from  RadComboBoxPositionControl), the  SqlDataSource4.UpdateParameters["Budget "].DefaultValue should be 209.89.

Thanks

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name == "Master")  
        {  
 
        ...  
        ...  
 
        }  
 
        GridDataItem parentItem = e.Item.OwnerTableView.ParentItem as GridDataItem;  
 
        if (parentItem != null)  
        {  
 
          SqlDataSource4.UpdateParameters["Budget"].DefaultValue =    ////Need Help here....
 
   
 
        }  
 
 
 
    }    
   
   
   
 
 

My Rad Combobox declaration again:

<telerik:RadComboBox ID="RadComboBoxPositionControl" runat="server"      
                                            DataSourceID="SqlDataSource5" DataTextField="PositionControlNum" DataValueField="PositionControlNum"      
                                            DropDownWidth="599px" Height="110px" HighlightTemplatedItems="true"      
                                            MarkFirstMatch="true"      
                                           SelectedValue='<%#Bind("PositionControlNum") %>' Width="600px"      
                                                 
                                            >    
                                            <HeaderTemplate>    
                                                <table cellpadding="0" cellspacing="0" style="width: 565px">     
                                                    <tr>    
                                                        <td style="width: 105px;">     
                                                            Position Control#</td>    
                                                            
                                         
                                            <td style="width: 75px;">     
                                                            Budget</td>    
                                                            ''     
                                                            ''         
                                                             
                                                    </tr>    
                                                </table>    
                                            </HeaderTemplate>    
                                            <ItemTemplate>    
                                                <table cellpadding="0" cellspacing="0" style="width: 565px">     
                                                    <tr>    
                                                      <td style="width: 105px;">     
    
                                                          <%# DataBinder.Eval(Container.DataItem, "PositionControlNum") %>    
                                                       </td>    
                                                         
                                                       <td style="width: 75px;">     
                                                       <%# DataBinder.Eval(Container.DataItem, "Budget", "{0:N2}")%>    
                                                           </td>      
                                                        ''     
                                                        ''     
                                                    </tr>    
                                                </table>    
                                            </ItemTemplate>    
                                                                                          
                                        </telerik:RadComboBox>    
                                            
 



 

 

0
gc_0620
Top achievements
Rank 1
answered on 27 Jan 2010, 11:32 PM
Any Response? Thanks
0
Yavor
Telerik team
answered on 29 Jan 2010, 07:04 AM
Hi,

Based on the supplied information, I still believe that my earlier suggestion is valid. You can get a reference to the control in the Update command. Subsequent to this, you can setup the relevant update parameters for SQLDatasource4.
If due to some reason this approach fails at your end, you can open a formal support ticket, and send us a small project, demonstrating your setup. We will review it locally, and get back to you with precise information on the matter.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Yavor
Telerik team
gc_0620
Top achievements
Rank 1
Share this question
or