<asp:Repeater id='Repeater1' runat='server'>
<ItemTemplate >
<b>
<u><p>
<%#GetFirstAlphabet(DataBinder.Eval(Container.DataItem, 'LastName').ToString())%>
</p></u>
</b>
<%#DataBinder.Eval(Container.DataItem, 'LastName').ToString()%>
,<%#DataBinder.Eval(Container.DataItem, 'FirstName').ToString()%><br>
</ItemTemplate>
</asp:Repeater>
VB.NET
If Not Page.IsPostBack Then
’Populate the Data in the Repeater
End If
protected function GetFirstAlphabet(ByVal strval As String) As String
Dim alphabet As String = ViewState('alphabet')
If alphabet = Left(strval, 1) Then
Return ''
Else
alphabet = Left(strval, 1)
ViewState('alphabet') = alphabet
Return alphabet
End If
End Function
C#
if(!Page.IsPostBack)
{
//Populate the Data in the Repeater
}
protected string GetFirstAlphabet(string strval)
{
string alphabet =(string) ViewState['alphabet'];
if( alphabet == strval.Substring(0,1) )
{
return '';
}
else
{
alphabet = strval.Substring(0,1);
ViewState['alphabet'] = alphabet;
return alphabet;
}
}
Share with