asp.Net Gridview shows datatype instead of value -


i've go little problem , can't find solution.

when gridview bound prices shown microsoft.xrm.sdk.money instead of value.

does know why happens , how change it?

here gridview:

<asp:gridview id="productlist"            runat="server"            autogeneratecolumns="false"            onrowdatabound="productlist_onrowdatabound">   <columns>     <asp:boundfield          headertext="productno."          datafield="productnumber"/>      <asp:boundfield          headertext="product"          datafield="name" />      <asp:boundfield          headertext="price/unit"          datafield="price" />   </columns> </asp:gridview> 

and fill teh following code

products = (from ppl in pricecatalog.price_level_product_price_levels             join prod in servicecontext.productset.tolist()                  on ppl.productid.id equals prod.productid             select new product()             {                 productid = prod.productid,                 productnumber = prod.productnumber,                 name = prod.name,                 price = prod.price,                 //price = ppl.amount.value,                 pricelevelid = ppl.pricelevelid,                 subjectid = prod.subjectid,                 defaultuomid = ppl.uomid             }).tolist();  var product = products.where(p => p.subjectid.id == filterto).tolist();  productlist.datakeynames = new[] { "productid" }; productlist.datasource = product.todatatable(xrmcontext); productlist.databind(); 

at moment looks this:

pno.     name        price  1        prod 1      microsoft.xrm.sdk.money 2        prod 2      microsoft.xrm.sdk.money 3        prod 3      microsoft.xrm.sdk.money .... 

on xrm.cs( generated file bind crm)

its following:

[microsoft.xrm.sdk.attributelogicalnameattribute("price")] public system.nullable<decimal> price {         {         return this.getattributevalue<system.nullable<decimal>>("price");     }     set     {         this.setattributevalue<microsoft.xrm.sdk.money>("price", "price", value);            } } 

you can use templatefield display value property (that contains decimal value) of price field. added column example

<asp:gridview id="productlist"            runat="server"            autogeneratecolumns="false"            onrowdatabound="productlist_onrowdatabound">   <columns>     <asp:boundfield          headertext="productno."          datafield="productnumber"/>      <asp:boundfield          headertext="product"          datafield="name" />      <asp:boundfield          headertext="price/unit"          datafield="price" />      <asp:templatefield headertext="price/unit decimal">         <itemtemplate>             <asp:label id="label1" runat="server" text='<%# bind("price.value") %>'></asp:label>         </itemtemplate>      </asp:templatefield>    </columns> </asp:gridview> 

Comments