ASPxCardView.InvalidCardIndex Field
Contains a value that is an invalid card index. This value is returned when an attempt to obtain a particular card fails, etc.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Field Value
Type |
---|
Int32 |
Example
The following example moves focus to a card that is not displayed on the current page. First, switch to the page that contains the required card, and then move the card focus.
protected void Button1_Click(object sender, EventArgs e)
{
// Obtain the visible index of the required card.
int cardIndex = ASPxCardView1.FindVisibleIndexByKeyValue("OLDWO");
if (cardIndex == ASPxCardView.InvalidCardIndex) return;
if (!IsCardVisibleOnScreen(cardIndex)) {
// Switch to the page that contains the required card.
GoToPage(cardIndex);
}
// Focus the required card.
ASPxCardView1.FocusedCardIndex = cardIndex;
}
bool IsCardVisibleOnScreen(int cardIndex)
{
int startIndex = ASPxCardView1.PageIndex * ASPxCardView1.SettingsPager.PageSize;
int endIndex = startIndex + ASPxCardView1.SettingsPager.PageSize;
return cardIndex >= startIndex && cardIndex < endIndex;
}
void GoToPage(int cardIndex)
{
ASPxCardView1.PageIndex = cardIndex / ASPxCardView1.SettingsPager.PageSize;
}
See Also