G
gt
I am trying to replicate the functionality of
DataTextField/DataValueFields in an extended DropDownList control that
I have created in order to provide a third value for each ListItem.
This value will be stored in a client-side array currently as that is
where it is required. Now to the problem.
I've overriden the DataBind Method of my DropDownList and within it
have added the code below:
Type DataSourceType = this.DataSource.GetType();
PropertyInfo LengthProperty = DataSourceType.GetProperty( "Count" );
MethodInfo get_ItemMethod = DataSourceType.GetMethod( "get_Item" );
if( LengthProperty != null && get_ItemMethod != null )
{
for( int i = 0; i < Convert.ToInt32( LengthProperty.GetValue(
DataSource, null) ); i++ )
{
object[] Parameters = new object[
get_ItemMethod.GetParameters().Length ];
Parameters[0] = i;
object CurrentObject = get_ItemMethod.Invoke( DataSource,
Parameters );
}
}
Now When I execute this code in debug mode, and break the Statement
LengthProperty.GetValue( DataSource, null) gives me an error in the
Watcher of
'error: arguments do not match parameters for function
'LengthProperty.GetValue''
Can anyone see where I may be going wrong here?
DataTextField/DataValueFields in an extended DropDownList control that
I have created in order to provide a third value for each ListItem.
This value will be stored in a client-side array currently as that is
where it is required. Now to the problem.
I've overriden the DataBind Method of my DropDownList and within it
have added the code below:
Type DataSourceType = this.DataSource.GetType();
PropertyInfo LengthProperty = DataSourceType.GetProperty( "Count" );
MethodInfo get_ItemMethod = DataSourceType.GetMethod( "get_Item" );
if( LengthProperty != null && get_ItemMethod != null )
{
for( int i = 0; i < Convert.ToInt32( LengthProperty.GetValue(
DataSource, null) ); i++ )
{
object[] Parameters = new object[
get_ItemMethod.GetParameters().Length ];
Parameters[0] = i;
object CurrentObject = get_ItemMethod.Invoke( DataSource,
Parameters );
}
}
Now When I execute this code in debug mode, and break the Statement
LengthProperty.GetValue( DataSource, null) gives me an error in the
Watcher of
'error: arguments do not match parameters for function
'LengthProperty.GetValue''
Can anyone see where I may be going wrong here?