Monday, November 23, 2009

SelectedIndex if nothing selected

SelectedIndex property of Infragistics' WebCombo class has the following syntax


public int SelectedIndex {get; set;}

The documentation reads 'If no row is selected, this property returns Nothing or Null.' That sounds suspiciously since int cannot be null.

The property actually returns -1 if there are no selected rows.

By the way, the index is zero-based, i.e. the first row has the index 0.

Thursday, November 12, 2009

'+' not supported in datakey

Users reported us that sometimes the selection is lost in UltraWebGrid. We managed to discover that the problem occurs only when the key column contains '+'. The selection is recognized OK on client side, but on server side it behaves as if the selected row was the one without '+', i.e. none if there was no such row.

Having the data source


[DataObject]
public class DataProvider
{
[DataObjectMethod(DataObjectMethodType.Select)]
public static IEnumerable SelectData()
{
yield return new { Column1 = "a+b" };
yield return new { Column1 = "a b" };
}
}

and the grid

<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="ObjectDataSource1">
<Bands>
<igtbl:UltraGridBand DataKeyField="Column1">
<Columns>
<igtbl:UltraGridColumn Key="Column1" BaseColumnName="Column1" IsBound="True"></igtbl:UltraGridColumn>
</Columns>
</igtbl:UltraGridBand>
</Bands>
<DisplayLayout …>…</DisplayLayout>
</igtbl:UltraWebGrid>

you can select the row with "a+b", but once you enter server code (e.g. for server event handling), the selection is changed to "a b".

We needed to introduce another column to store the key value with '+' escaped somehow (e.g. replaced for another character).

Updated 3 February 2010:
I have been told by a colleague that even server events are not raised for a row having '+' in its key.