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

RadCombobox in RadGrid

4 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
S L
Top achievements
Rank 1
S L asked on 11 Jul 2013, 03:27 AM
I want to use the RadGrid for user to do data entry
inside the grid, there was a few of RadComboBox, RadNumericTextBox for edit.

i want to use the Add Row Button outside the grid, i use the following methods and it did not work
1) i have try add new row on the datatable and rebind grid
2) RadGrid1.MasterTableView.IsItemInserted = True

i want to know if the grid can do a multi row edit, where user can select any item to edit without the needs to click the Edit and Update button on the grid, and click the Submit button out of the grid the save the data.

i face a problem on data binding the grid, and it is saying System.ArgumentException: Grid Data Source Error :Column 'invBCItm_guid' does not belong to table .
i having the column in the datatable and the ASPX

 i am newbie to telerik, i need some information & guides on this.

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Jul 2013, 05:09 AM
Hello,

You have assigned "'invBCItm_guid"  as DataField in one of the column and RadGrid not able to find this 'invBCItm_guid" in DataSource.

Note : Please check that "'invBCItm_guid" is exists in your Assigned Datasource or not.

Thanks,
Jayesh Goyani
0
S L
Top achievements
Rank 1
answered on 11 Jul 2013, 05:35 AM
i have this in datatable and the ASPX file. below is the markup:
<telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" ShowStatusBar="true" AutoGenerateColumns="true"
                            PageSize="10" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True"
                            OnNeedDataSource="RadGrid1_NeedDataSource" Skin="MyCustomSkin" EnableEmbeddedSkins="false"
                            OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated">
                            <PagerStyle Mode="NumericPages"></PagerStyle>
                            <MasterTableView Name="Criteria" CommandItemDisplay="Top" EditMode="EditForms" DataKeyNames="OutcomeClinic_ID"
            <Columns>
                <telerik:GridBoundColumn DataField="invBCItm_guid" HeaderText="Item ID" SortExpression="invBCItm_guid" UniqueName="invBCItm_guid" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_branch" HeaderText="Ordering Branch" SortExpression="invBCItm_branch" UniqueName="invBCItm_branch" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_src_location"  HeaderText="Source" SortExpression="invBCItm_src_location" UniqueName="invBCItm_src_location" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_dest_location"  HeaderText="Destination" SortExpression="invBCItm_dest_location" UniqueName="invBCItm_dest_location" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_bill_acc"  HeaderText="Billing Account"  SortExpression="invBCItm_bill_acc" UniqueName="invBCItm_bill_acc" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_chrgrate_wd" HeaderText="Weekday" SortExpression="invBCItm_chrgrate_wd" UniqueName="invBCItm_chrgrate_wd" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_chrgrate_we" HeaderText="Weekend"  SortExpression="invBCItm_chrgrate_we" UniqueName="invBCItm_chrgrate_we" Visible="false"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_chrgrate_ph"  HeaderText="Public Holiday"  SortExpression="invBCItm_chrgrate_ph" UniqueName="invBCItm_chrgrate_ph" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="invBCItm_revcode"  HeaderText="Revenue Code"  SortExpression="invBCItm_revcode" UniqueName="invBCItm_revcode" Visible="false"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" Text="Edit" ImageUrl="~/images/edit.gif" UniqueName="column" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to edit this row"><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridButtonColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete" ImageUrl="~/images/delete.gif" UniqueName="column" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this row"><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridButtonColumn>
            </Columns>
                        <EditFormSettings EditFormType="Template"
                                <EditColumn CancelImageUrl="~/images/Cancel.gif" EditImageUrl="~/images/Edit.gif" InsertImageUrl="~/images/Update.gif" UpdateImageUrl="~/images/Update.gif" ButtonType="ImageButton" UniqueName="EditCommandColumn1" ></EditColumn
                                <FormTemplate>  
                                   <div id="EditForm"
                                      <table class="Container"  width="100%" >
                                    <tr>
                                        <td>Ordering Branch</td>
                                        <td>
                                            <telerik:RadComboBox ID="ddlOrderingBranch" runat="server" Width="200px" AppendDataBoundItems="true" ToolTip="Ordering Branch" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("branch_guid") %>'></telerik:RadComboBox>
                                        </td>
                                           
                                    </tr>
                                    <tr>
                                        <td>Souce</td>
                                        <td>
                                            <telerik:RadComboBox ID="ddlSource" runat="server" Width="200px" AppendDataBoundItems="true" ToolTip="Source" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("location_guid") %>'></telerik:RadComboBox>
                                            <asp:RequiredFieldValidator ID="rfvddlSource" runat="server" ControlToValidate="ddlSource"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>Destination</td>
                                        <td>
                                            <telerik:RadComboBox ID="ddlDestination" runat="server" Width="200px"  AutoPostBack="true" AppendDataBoundItems="true" ToolTip="Site" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("location_guid") %>'></telerik:RadComboBox>
                                            <asp:RequiredFieldValidator ID="rfvddlDestination" runat="server" ControlToValidate="ddlDestination"></asp:RequiredFieldValidator>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>Billing Account</td>
                                        <td>
                                            <telerik:RadComboBox ID="ddlBillingAccount" runat="server" Width="200px"  AutoPostBack="true" AppendDataBoundItems="true" ToolTip="Billing Account" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("invdef_seq") %>'></telerik:RadComboBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Weekday</td>
                                        <td>
                                            <telerik:RadNumericTextBox ID="ntxWeekday" runat="server" Width="200px" CssClass="TextBoxDecorator"></telerik:RadNumericTextBox>
                                        </td>
                                        <td>Weekend</td>
                                        <td><telerik:RadNumericTextBox ID="ntxWeekend" runat="server" Width="200px" CssClass="TextBoxDecorator"></telerik:RadNumericTextBox></td
                                        <td>Public Holiday</td>
                                        <td><telerik:RadNumericTextBox ID="ntxPublicHoliday" runat="server" Width="200px" CssClass="TextBoxDecorator"></telerik:RadNumericTextBox></td
                                    </tr>
                                    <tr>
                                        <td>Revenue Code</td>
                                        <td>
                                            <telerik:RadComboBox ID="ddlRevenueCode" runat="server" Width="200px"  AutoPostBack="true" AppendDataBoundItems="true" ToolTip="Revenue Code" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("invrev_guid") %>'></telerik:RadComboBox>
                                        </td>
                                    </tr>
                                    <tr>
                                    <td> </td>
                                    <td colspan="2"
                                            <asp:Button ID="btnUpdate" cssclass="gridbtn_80" Text='<%#iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "Insert","Update")  %>' runat="server" CommandName='<%# iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert", "Update" )%>'></asp:Button>   
                                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" cssclass="gridbtn_80" CommandName="Cancel"/>    
                                    </td>
                                    </tr>
                                    </table>
                                   </div>
                                </FormTemplate>   
                        </EditFormSettings>
            <CommandItemSettings AddNewRecordText="Add new Criteria" RefreshText=" " ShowAddNewRecordButton="false"/>
            <RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn
            <ExpandCollapseColumn><HeaderStyle Width="20px" /></ExpandCollapseColumn>
            </MasterTableView
</telerik:RadGrid>
i have no idea why it is showing this error could not find the column.
i have bind the datatable
Dim dtDetail as Datatable = New Datatable
 
Dim dr As DataRow
dr = dtDetail.NewRow
 
dr("invBCItm_guid") = -1
dr("invBCItm_branch") = ""
dr("invBCItm_src_location") = ""
dr("invBCItm_dest_location") = ""
dr("invBCItm_bill_acc") = ""
dr("invBCItm_chrgrate_wd") = 0
dr("invBCItm_chrgrate_we") = 0
dr("invBCItm_chrgrate_ph") = 0
dr("invBCItm_revcode") = ""
 
dtDetail.Rows.Add(dr)
RadGrid1.DataSource = dtDetail
0
Accepted
Princy
Top achievements
Rank 1
answered on 17 Jul 2013, 11:53 AM
Hi,

Please try adding the columns as follows.

VB:
Dim dtDetail As New DataTable()
 
    Dim dr As DataRow = Nothing
    dr = dtDetail.NewRow()
    dtDetail.Columns.Add("invBCItm_guid")
    dtDetail.Columns.Add("invBCItm_branch")
    dtDetail.Columns.Add("invBCItm_src_location")
    dtDetail.Columns.Add("invBCItm_dest_location")
    dtDetail.Columns.Add("invBCItm_bill_acc")
    dtDetail.Columns.Add("invBCItm_chrgrate_wd")
    dtDetail.Columns.Add("invBCItm_chrgrate_we")
    dtDetail.Columns.Add("invBCItm_chrgrate_ph")
    dtDetail.Columns.Add("invBCItm_revcode")
 
    dr("invBCItm_guid") = -1
    dr("invBCItm_branch") = ""
    dr("invBCItm_src_location") = ""
    dr("invBCItm_dest_location") = ""
    dr("invBCItm_bill_acc") = ""
    dr("invBCItm_chrgrate_wd") = 0
    dr("invBCItm_chrgrate_we") = 0
    dr("invBCItm_chrgrate_ph") = 0
    dr("invBCItm_revcode") = ""
 
    dtDetail.Rows.Add(dr)
    RadGrid1.DataSource = dtDetail

Thanks,
Princy.
0
S L
Top achievements
Rank 1
answered on 18 Jul 2013, 06:15 AM
Dim dtDetail As New DataTable()
 
dtDetail.Columns.Add("invBCItm_guid")
dtDetail.Columns.Add("invBCItm_branch")
dtDetail.Columns.Add("invBCItm_src_location")
dtDetail.Columns.Add("invBCItm_dest_location")
dtDetail.Columns.Add("invBCItm_bill_acc")
dtDetail.Columns.Add("invBCItm_chrgrate_wd")
dtDetail.Columns.Add("invBCItm_chrgrate_we")
dtDetail.Columns.Add("invBCItm_chrgrate_ph")
dtDetail.Columns.Add("invBCItm_revcode")
Dim dr As DataRow = Nothing
 
dr = dtDetail.NewRow()
 
dr("invBCItm_guid") = -1
dr("invBCItm_branch") = ""
dr("invBCItm_src_location") = ""
dr("invBCItm_dest_location") = ""
dr("invBCItm_bill_acc") = ""
dr("invBCItm_chrgrate_wd") = 0
dr("invBCItm_chrgrate_we") = 0
dr("invBCItm_chrgrate_ph") = 0
dr("invBCItm_revcode") = ""
 
dtDetail.Rows.Add(dr)
RadGrid1.DataSource = dtDetail
yes, i realized that forgotten to update here. the columns should add before using datarow.
Tags
Grid
Asked by
S L
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
S L
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or