views:

219

answers:

2

How to replace cell value with their description. This is my grid

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None">
     <HeaderContextMenu EnableAutoScroll="True">
     </HeaderContextMenu>
     <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SqlDataSource1">
        <RowIndicatorColumn>
           <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
           <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
           <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID"
              ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"
              UniqueName="CustomerID">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" HeaderText="OrderDate"
              SortExpression="OrderDate" UniqueName="OrderDate">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="RequiredDate" DataType="System.DateTime" HeaderText="RequiredDate"
              SortExpression="RequiredDate" UniqueName="RequiredDate">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" SortExpression="ShipName"
              UniqueName="ShipName">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipAddress" HeaderText="ShipAddress" SortExpression="ShipAddress"
              UniqueName="ShipAddress">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" SortExpression="ShipCity"
              UniqueName="ShipCity">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipRegion" HeaderText="ShipRegion" SortExpression="ShipRegion"
              UniqueName="ShipRegion">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipPostalCode" HeaderText="ShipPostalCode" SortExpression="ShipPostalCode"
              UniqueName="ShipPostalCode">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="ShipCountry" SortExpression="ShipCountry"
              UniqueName="ShipCountry">
           </telerik:GridBoundColumn>
        </Columns>
     </MasterTableView>
  </telerik:RadGrid>

This grid will load Orders table. How to replace CustomerID with CompanyName which is come from Customers table during run time?

A: 

Bind the grid to a DataView object that includes the CompanyName field from the Customers table.

DaMartyr
How to do that? can you show me some link? Already try but didn't find
shoden
There are a lot of examples on how to make a dataview. Point the datasource to the dataview. Since you're pulling a field from a different table, you should do an inner-join sql query to pull that field too.
DaMartyr
A: 

You can use a LinqDataSource with a Linq-to-SQL model. If Orders has a foreign key field that references Customers table, then the corresponding association will be created for you automatically by Linq-to-SQL designer when you drag out the tables into the designer. If the FK relationship does not exist in the DB, you can still model it in Linq-to-SQL very simply. Once the association is defined, the Orders class acquires a new Property, likely called Customer, that will expose a Customer object. You can then access it either declaratively or programmatically by simply using the dot notation, like so: DataField="Customer.Name"

Antony Highsky