I have a grid with a dropdown provider and want to display "UserName" from the dropdown in each row of the grid. The grid's bound column is "UserID" in both the main datasource and the dropdown.
How would I set the main grid column to display the UserName?
Here is the code as it is now. Any help would be appreciated.
<asp:ObjectDataSource ID="dsRoutes" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="dsRoutesTableAdapters.ROUTETableAdapter" DeleteMethod="Delete" InsertMethod="Insert" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_STOREID" Type="Int32"></asp:Parameter> <asp:Parameter Name="Original_RouteID" Type="String"></asp:Parameter> </DeleteParameters> <InsertParameters> <asp:Parameter Name="STOREID" Type="Int32"></asp:Parameter> <asp:Parameter Name="RouteID" Type="String"></asp:Parameter> <asp:Parameter Name="Description" Type="String"></asp:Parameter> <asp:Parameter Name="UserID" Type="Int32"></asp:Parameter> <asp:Parameter DbType="Guid" Name="msrepl_tran_version"></asp:Parameter> <asp:Parameter Name="ACTIVE" Type="Boolean"></asp:Parameter> </InsertParameters> <UpdateParameters> <asp:Parameter Name="Description" Type="String"></asp:Parameter> <asp:Parameter Name="UserID" Type="Int32"></asp:Parameter> <asp:Parameter DbType="Guid" Name="msrepl_tran_version"></asp:Parameter> <asp:Parameter Name="ACTIVE" Type="Boolean"></asp:Parameter> <asp:Parameter Name="Original_STOREID" Type="Int32"></asp:Parameter> <asp:Parameter Name="Original_RouteID" Type="String"></asp:Parameter> </UpdateParameters></asp:ObjectDataSource>
<asp:ObjectDataSource ID="dsManagers" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="dsListUsersTableAdapters.prc_RAMUserMgrTableAdapter"> <SelectParameters> <asp:SessionParameter SessionField="storeID" Name="storeid" Type="Int32"></asp:SessionParameter>
</SelectParameters></asp:ObjectDataSource><ig:WebDataGrid ID="GrdRoutes" runat="server" Height="600px" DataSourceID="dsRoutes" AutoGenerateColumns="False" DataKeyFields="STOREID, RouteID"> <Columns> <ig:BoundDataField DataFieldName="STOREID" Key="STOREID" Hidden="true"> <Header Text="STOREID"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RouteID" Key="RouteID" Width="100px"> <Header Text="Code"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Description" Key="Description" Width="200px"> <Header Text="Name"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="UserID" Key="UserID" Width="200px"> <Header Text="Manager"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="msrepl_tran_version" Key="msrepl_tran_version" Hidden="true"> <Header Text="msrepl_tran_version"></Header> </ig:BoundDataField> <ig:BoundCheckBoxField DataFieldName="ACTIVE" Key="ACTIVE" Width="100px" CheckBox-CheckedImageUrl="../../../Graphics/Icons/Active.png" CheckBox-PartialImageUrl="../../../Graphics/Icons/Inactive.png" CheckBox-UncheckedImageUrl="../../../Graphics/Icons/Inactive.png" CssClass="centerItem"> <Header Text="Active"></Header> </ig:BoundCheckBoxField> </Columns> <EditorProviders> <ig:DropDownProvider ID="ddManagers" EditorControl-DropDownContainerMaxHeight="250" EditorControl-DropDownContainerHeight="0px" > <EditorControl ID="EditorControl1" runat="server" DisplayMode="DropDownList" TextField="UserNAME" ValueField="UserID" Button-ImageUrl="/Graphics/Icons/DropdownArrow.png" Button-HoverImageUrl="/Graphics/Icons/DropdownArrowHover.png" Button-PressedImageUrl="/Graphics/Icons/DropdownArrowPressed.png"> <Button PressedImageUrl="/Graphics/Icons/DropdownArrowPressed.png" ImageUrl="/Graphics/Icons/DropdownArrow.png" HoverImageUrl="/Graphics/Icons/DropdownArrowHover.png"></Button> <Items> <ig:DropDownItem>
</ig:DropDownItem> </Items> <ItemTemplate> <ig:WebDataGrid ID="grdManagers" runat="server" AutoGenerateColumns="False" DataSourceID="dsManagers" DataKeyFields="UserID">
<Columns> <ig:BoundDataField DataFieldName="UserID" Key="UserID" Hidden="false" Width="100px"> <Header Text="UserID"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="UserNAME" Key="UserNAME" Width="200px"> <Header Text="UserNAME"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="INITIALS" Key="INITIALS" Width="100px"> <Header Text="INITIALS"></Header> </ig:BoundDataField> </Columns> <Behaviors> <ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Row"> <SelectionClientEvents RowSelectionChanged="rowSelChange" /> </ig:Selection> </Behaviors> </ig:WebDataGrid> </ItemTemplate>
</EditorControl> </ig:DropDownProvider>
</EditorProviders> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing> <EditModeActions MouseClick="Single" EnableOnActive="True" /> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="UserID" EditorID="ddManagers" /> </ColumnSettings> </ig:CellEditing> <ig:RowAdding Alignment="Top"> <EditModeActions MouseClick="Single" EnableOnActive="True" EnableOnKeyPress="True" /> </ig:RowAdding> <ig:RowDeleting /> </Behaviors> </ig:EditingCore> <ig:Activation> </ig:Activation> <ig:Selection CellClickAction="Row" RowSelectType="Single"> </ig:Selection> <ig:RowSelectors> </ig:RowSelectors> <ig:Filtering> </ig:Filtering> <ig:Sorting> </ig:Sorting> <ig:ColumnResizing> </ig:ColumnResizing> <ig:Clipboard> </ig:Clipboard> </Behaviors></ig:WebDataGrid>
<script type="text/javascript">
function rowSelChange(sender, args) { var dd = $find('<%= ddManagers.EditorControl.ClientID%>'); var row = args.getSelectedRows().getItem(0).get_cell(0).get_text(); dd.set_currentValue(row, true); dd._elements["Input"].focus(); dd.closeDropDown();
}
function cancelDDSel(sender, args) { args.set_cancel(true); } </script>
Hi lburns,
Please let me know if you need any additional assistance.
To accomplish this, you can set the EditorControl 'TextField' property to UserName, and set the 'ValueField' to UserID.
Let me know if you need any additional assistance.