# Radzen Tab does not output correct selected index

**URL:** <https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364>\
**Category:** Radzen.Blazor Components\
**Created:** [October 21, 2020, 11:27pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364 "2020-10-21T23:27:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elgardoe](https://forum.radzen.com/user_avatar/forum.radzen.com/elgardoe/32/4601_2.png) [@elgardoe](https://forum.radzen.com/u/elgardoe)\
**Post date:** [October 21, 2020, 11:27pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/1 "2020-10-21T23:27:04Z")

</div>

Was on version 2.15.8 and the "SelectedIndex" property for RadzenTabs was working as expected. On version 2.15.16 the "SelectedIndex" no longer works. It's output is "-1".

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 22, 2020, 3:32am UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/2 "2020-10-22T03:32:55Z")

</div>

You should now use `@bind-SelectedIndex` if you want to keep it in sync.

```auto
<RadzenTabs @bind-SelectedIndex=@selectedIndex>
</RadzenTabs>

@code {
   int selectedIndex = 0;
}

```

---

<div class="post-metadata">

**Author:** ![elgardoe](https://forum.radzen.com/user_avatar/forum.radzen.com/elgardoe/32/4601_2.png) [@elgardoe](https://forum.radzen.com/u/elgardoe)\
**Post date:** [October 22, 2020, 1:47pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/3 "2020-10-22T13:47:07Z")

</div>

Thanks.

I needed to subscribe to the selected index change event so I was able to get the selected index through the event.

SelectedIndexChanged="@(arg =\> OnTabChange(arg))"

---

<div class="post-metadata">

**Author:** ![kgordon](https://forum.radzen.com/user_avatar/forum.radzen.com/kgordon/32/2245_2.png) [@kgordon](https://forum.radzen.com/u/kgordon)\
**Post date:** [October 12, 2021, 6:04pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/4 "2021-10-12T18:04:41Z")

</div>

@korchev I'm not sure I follow. Does this mean I have to hardcode @bind-SelectedIndex into the .razor page? I've set the SelectedIndex as in the image below, but it doesn't seem to allow me to change the tab programmatically. This only creates a SelectedIndex in the .razor page. I don't want to hardcode because Radzen will overwrite it every time I make changes to the form. Please let me know what I'm missing. One additional note, the selected checkbox seems to override the SelectedIndex value. This causes problems because it forces the developer to ensure that none of the tabs are set to selected after every time they make changes to one of the tabs. Having SelectedIndex be the driving force is a much better way of handling it. That way I can write it in code and not worry about it being overwritten accidentally.

 ![image](https://forum.radzen.com/uploads/default/original/2X/1/110e3bd73d819e776305558e5fc38750308ddef5.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 12, 2021, 6:20pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/5 "2021-10-12T18:20:46Z")

</div>

> [@kgordon](#):
>
> Does this mean I have to hardcode @bind-SelectedIndex into the .razor page?

No. You can set it as a custom attribute.

> [@kgordon](#):
>
> Please let me know what I'm missing

Radzen regenerates all pages unless they are added to the code generation ignore list.

> [@kgordon](#):
>
> One additional note, the selected checkbox seems to override the SelectedIndex value.

This is by design at the moment.

---

<div class="post-metadata">

**Author:** ![kgordon](https://forum.radzen.com/user_avatar/forum.radzen.com/kgordon/32/2245_2.png) [@kgordon](https://forum.radzen.com/u/kgordon)\
**Post date:** [October 12, 2021, 6:36pm UTC](https://forum.radzen.com/t/radzen-tab-does-not-output-correct-selected-index/5364/6 "2021-10-12T18:36:01Z")

</div>

> [@kgordon](#):
>
> @bind-SelectedIndex

Ok thanks. I think I get it. I'll run some more tests.
