Live Chat Icon For mobile
Live Chat Icon

How to display alphabetically sorted data in Repeater

Platform: ASP.NET| Category: Repeater

<asp:Repeater id='Repeater1' runat='server'>
<ItemTemplate >
	<%#GetFirstAlphabet(DataBinder.Eval(Container.DataItem, 'LastName').ToString())%>
<%#DataBinder.Eval(Container.DataItem, 'LastName').ToString()%>
,<%#DataBinder.Eval(Container.DataItem, 'FirstName').ToString()%><br>


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 ''
	alphabet = Left(strval, 1)
	ViewState('alphabet') = alphabet
	Return alphabet
End If
End Function


	//Populate the Data in the Repeater		

protected string GetFirstAlphabet(string strval)
	string  alphabet   =(string) ViewState['alphabet'];
	if( alphabet == strval.Substring(0,1) )
		return '';
		alphabet = strval.Substring(0,1);
		ViewState['alphabet'] = alphabet;
		return alphabet;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.