This sample code will help you to format infragistics dropdown values using pre and post spaces. suppose that you are getting name and id column in Ds dataset and you want to add these values in cmbList infragistics dropdown.
Loop through each and every values and replace black values with . also you need to decode the given string and add to combo list.
ASP.NET Code:
Register section:
<%@ Register Assembly="MultiSelectDropdownList" Namespace="MultiSelectDropdownList"
TagPrefix="cmb" %>
Tag Definition:
<cmb:MultiSelectDropdownList ID="cmbList" runat="server" >
</cmb:MultiSelectDropdownList>
C# Code:
public void FormattedCombo(DataSet Ds)
{
int i = 0;
for (i = 0; i < Ds.Tables[0].Rows.Count; i++)
{
System.IO.StringWriter writer = new System.IO.StringWriter();
string str = Ds.Tables[0].Rows[i]["Name"].ToString().Replace(" ", " ");
Server.HtmlDecode(str, writer);
cmbList.Items.Insert(i + 1, new ListItem(writer.ToString(), Ds.Tables[0].Rows[i]["id"].ToString()));
writer.Close();
}
}
No comments:
Post a Comment