Sample Code: How to display multiple spaces in a dropdownlist
ASP.NET
Thread Starter: Paschal
Started:
Replies: 0

Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » Sample Code: How to display multiple spaces in a dropdownlist
« Previous Thread Next Thread »
   30 Oct 2004, 7:00
Paschal is not online. Last active: 21/01/2005 18:37:42 Paschal
Sample Code: How to display multiple spaces in a dropdownlist

webform1.aspx

VB.NET Code

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# Code

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);
}


  
  Page 1 of 1 (1 items)
Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » Sample Code: How to display multiple spaces in a dropdownlist

Powered by Community Server :: Forums