Live Chat Icon For mobile
Live Chat Icon

How to display multiple spaces in a dropdownlist

Platform: ASP.NET| Category: Dropdownlist

<asp:DropDownList id='DropDownList1' runat='server'></asp:DropDownList>

VB.NET


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	’Put user code to initialize the page here
	Dim i As Integer
	For i = 0 To 10
		DropDownList1.Items.Add('Item Number' + SpaceDDL(10) + i.ToString)
	Next
End Sub
  
Private Function SpaceDDL(ByVal numberOfSpaces As Integer) As String
  	Dim Spaces As String
	Dim i As Integer
	For i = 0 To numberOfSpaces
	            Spaces &= ' '
	Next
	Return Server.HtmlDecode(Spaces)
End Function

C#


private void Page_Load(object sender, System.EventArgs e)
{
	// Put user code to initialize the page here
  	for(int i = 0 ;i<=10;i++)
	{
		DropDownList1.Items.Add('Item Number' + SpaceDDL(10) + i.ToString());
	}
}

string SpaceDDL(int numberOfSpaces )  
{
	string Spaces=''; 
	for(int i = 0 ;i<=numberOfSpaces;i++)
	{
		Spaces += ' ';
	}
	return Server.HtmlDecode(Spaces);
}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.