Fengzhimei@Dot.Net
Designing My Colorful Dream

   I am using a Datagrid and am populating the column header which is being picked up from a database,the Datagrid also contains some template column,you know,i must use DataBinder.Eval(Container.DataItem,'column name') to bind the datasource.

   My problem is that if the 'column name' contains a '.' within(eg:urn:schemas.microsoft.com:fulltextqueryinfo:displaytitle) then it throws an error as follows:

   DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name 'column name'.

   I'm not sure if it is a bug of Datagird,but the error exists indeed,you can try it:)

   But  when i change to use DataBinder.GetPropertyValue(Container.DataItem, 'column name') method,everything goes well.

   And the another way is write a custom function,then you can call it from the template column.here is the code sample:

   public string ChangeValue(object dataItem,string columnName)
   {
         return ((DataRowView)dataItem)[columnName].ToString();
   }

   I hope this helps.

posted on 2003-12-28 08:23  fengzhimei  阅读(918)  评论(0编辑  收藏  举报