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

DropDown Column in RADGRID

2 Answers 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 22 May 2014, 05:48 PM
Hello,

I was wondering if someone could help me here. I have read both this and this but still struggling on what I am trying to do.

Here is my RAD GRID below

<telerik:RadGrid ID="rgDocuments" runat="server" DataSourceID="AssetDocument" AutoGenerateEditColumn="True" AllowAutomaticUpdates="True">
                                      <MasterTableView AutoGenerateColumns="False" DataKeyNames="Doc_DocumentID" DataSourceID="AssetDocument">
                                          <Columns>
                                              <telerik:GridBoundColumn Visible="false" ReadOnly="True"  DataField="Doc_DocumentID" FilterControlAltText="Filter Doc_DocumentID column" HeaderText="Doc_DocumentID" SortExpression="Doc_DocumentID" UniqueName="Doc_DocumentID">
 
                                              </telerik:GridBoundColumn>
                                              <telerik:GridTemplateColumn AllowFiltering="false" UniqueName="LessonColumn">
                                                  <ItemTemplate>
                                                      <a href="Download.aspx?File=<%#Eval("Doc_FullFilePath")%>">
                                                          <asp:Image ImageUrl="images/download.jpg"
                                                              ID="imgTest" runat="server" Height="25px" Width="25px" />
                                                      </a>
                                                  </ItemTemplate>
                                              </telerik:GridTemplateColumn>
 
                                              <telerik:GridButtonColumn HeaderText="Delete" ButtonType="ImageButton" CommandName="Delete"
                                                  FilterControlAltText="Filter DeleteColumn column"
                                                  ImageUrl="~/Images/delete_97221.jpg" Text="Delete"
                                                  UniqueName="DeleteColumn" Resizable="false" ConfirmText="Are you sure you wish to delete this document from this asset?">
                                                  <HeaderStyle CssClass="rgHeader ButtonColumnHeader"></HeaderStyle>
                                                  <ItemStyle CssClass="ButtonColumn" />
                                              </telerik:GridButtonColumn>
                                              <telerik:GridDropDownColumn EditFormColumnIndex="1" DataSourceID="DropDown" ListTextField="FieldAnswer" ListValueField="IDNo"
                                                  UniqueName="Doc_CategoryID" HeaderText="Category Column" DataField="Doc_CategoryID"
                                                  AllowAutomaticLoadOnDemand="true"
                                                  AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10">
                                              </telerik:GridDropDownColumn>
                                                                                            <telerik:GridBoundColumn DataField="Doc_Description" FilterControlAltText="Filter Doc_Description column" HeaderText="Description" SortExpression="Doc_Description" UniqueName="Doc_Description">
                                                  <ColumnValidationSettings>
                                                      <ModelErrorMessage Text="" />
                                                  </ColumnValidationSettings>
                                              </telerik:GridBoundColumn>
                                          </Columns>
                                      </MasterTableView>
                                  </telerik:RadGrid>

Below are the two SQL Data Sources.

The link between them is that the Table "Documents" Column "Doc_CategoryID" should match up to the Table "Customisation" column IDNO and the available choices which the user can select should be displayed from the Table "Customisation" Column "FieldAnswer".

  <asp:SqlDataSource ID="AssetDocument" runat="server" ConnectionString="<%$ ConnectionStrings:SD %>" SelectCommand="Select Doc_DocumentID,Doc_Description,Doc_LongNotes, Doc_FilePath,Doc_FileName,Doc_CategoryID, Doc_FilePath + Doc_FileName as Doc_FullFilePath from Documents where Doc_AssetID = @AssetID and Doc_Deleted is null order by Doc_DocumentID ASC" UpdateCommand="UPDATE Documents SET Doc_Description = @Doc_Description WHERE (Doc_DocumentID = @Doc_DocumentID) AND (Doc_Deleted IS NULL)">
                <SelectParameters>
                    <asp:SessionParameter DefaultValue="0" Name="AssetID" SessionField="AssetID" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Doc_Description" />
                  <asp:Parameter Name="Doc_DocumentID" />
                </UpdateParameters>
            </asp:SqlDataSource>
 
 
<asp:SqlDataSource ID="DropDown" runat="server" ConnectionString="<%$ ConnectionStrings:SD %>" SelectCommand="SELECT IDNO, FieldAnswer from easb_Customisation WHERE (([ScreenName] = 'Documents') AND ([FieldName] = 'Category')) ORDER BY [OrderBy], [FieldAnswer]"></asp:SqlDataSource>
 
The part where it fails to work is when the user clicks the Edit Button on the RadGrid, it just errors out saying this below. I have tried different options in the UniqueName but none of them i have tried is working. Any ideas?  

Server Error in '/' Application.
 
Editor cannot be initialized for column: Doc_CategoryID
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
 Exception Details: Telerik.Web.UI.GridColumnEditorException: Editor cannot be initialized for column: Doc_CategoryID
 
Source Error:
 
 
 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Thanks,
Alex


2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 May 2014, 10:19 AM
Hi Alex,

Please remove EditFormColumnIndex="1" from the GridDropDownColumn and check if the issue exists. If you want to set this property you should also set the ColumnNumber property of the of the EditFormSettings in the MasterTableView. It specifies how many groups of columns you will have in the autogenerated edit form, the default is 1 and you have to set bigger value if you need to set different EditFormIndexes.

ASPX:
<MasterTableView>
  <EditFormSettings ColumnNumber="2" />
   <Columns>
      <telerik:GridDropDownColumn EditFormColumnIndex="1" . . .>
      </telerik:GridDropDownColumn>
   </Columns>
</MasterTableView>

Thanks,
Shinu
0
Alex
Top achievements
Rank 1
answered on 23 May 2014, 03:15 PM
Thanks for that. It is now working as expected.


Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alex
Top achievements
Rank 1
Share this question
or