Can any one tell me i have used here DataTextFormatString but it is not working can any one help me...?
DropDownList Problem
hi dudes
Can any one tell me i have used here DataTextFormatString but it is not working can any one help me...?
1 2 3 5 6 8
Can any one tell me i have used here DataTextFormatString but it is not working can any one help me...?

Blocked AccountPosted Jul 12, 2011, 9:08 AM
DataTextFormatString works when DataTextField property is set.
try this:
<asp:DropDownList ID="DDLDollar" DataTextFormatString="{0:C}" DataTextField="Text" DataValueField="Value" runat="server">
asp:DropDownList>
and bind it in .cs file like that(I have created temp table for showing you result, you can use according to your need )
DataTable dataTabel = new DataTable("myDynamicTable");
DataColumn _columnValue = new DataColumn();
DataColumn _columnText = new DataColumn();
_columnValue.ColumnName = "Value";
_columnValue.DataType = Type.GetType("System.Int32");
_columnText.ColumnName = "Text";
_columnText.DataType = Type.GetType("System.Int32");
// Add these DataColumns into the DataTable
dataTabel.Columns.Add(_columnValue);
dataTabel.Columns.Add(_columnText);
DataRow newRow = dataTabel.NewRow();
newRow["Text"] = 1;
newRow["Value"] = 1;
// Add the row into the table
dataTabel.Rows.Add(newRow);
DDLDollar.DataSource = dataTabel;
DDLDollar.DataBind();