We have a GridView that bind to some data and it look like this:
RowNumber Id Desc
-------------------------------------------
1 20 Desc1
2 30 Desc2
3 40 Desc3
4 50 Desc4
I create RowNumber using this code:
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="lblSlNo" runat="server" Text='<% #Container.DataItemIndex + 1 %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
So considering that during data binding, I don’t want show second row but I want keep RowNumber for it. The data should show like this:
RowNumber Id Desc
-------------------------------------------
1 20 Desc1
3 40 Desc3
4 50 Desc4
How I can prevent a row add to GridView during Databinding?
Try this:
Where someCondition is your checking.