hi
refer below thread
http://www.aspforums.net/Threads/110747/How-to-bind-DropdownList-with-Persian-numeric-values-using-C-in-ASPNet/
I used below code for binding DropDownlist in persian language:
protected void BindDropDownList1(DropDownList DDL, string spname, string dataTextfield, string dataValuefield)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand(spname, conn))
{
if (DDL.ID.ToUpper() != "ddlzone".ToUpper()) // pass the dropdownlist Id which you want to bind in perisan numbering.
{
conn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
if (_dr.HasRows)
{
DDL.DataSource = _dr;
DDL.DataTextField = dataTextfield;
DDL.DataValueField = dataValuefield;
DDL.DataBind();
}
conn.Close();
}
else
{
DataTable dtPersianTable = new DataTable();
dtPersianTable.Columns.Add("persian");
SqlDataAdapter sda = new SqlDataAdapter(_cmd);
DataTable dtDataBaseTable = new DataTable();
sda.Fill(dtDataBaseTable);
for (int i = 0; i < dtDataBaseTable.Rows.Count; i++)
{
dtPersianTable.Rows.Add(toPersianNumber(dtDataBaseTable.Rows[i]["Regionname"].ToString())); // table column name which holds the value in numbers needs to be converted to persian.
}
DDL.DataSource = dtPersianTable;
DDL.DataTextField = "persian";
DDL.DataValueField = "persian";
DDL.DataBind();
}
}
}
}
how I can use above code for below code:
private void BindRegion()
{
ddlzone.Items.Clear();
ddlzone.Items.Insert(0, new ListItem("همه", "0"));
ddlzone.AppendDataBoundItems = true;
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("selectregion", conn))
{
_cmd.Parameters.AddWithValue("@CityID", DDLcity.SelectedItem.Text);
conn.Open();
ddlzone.DataSource = _cmd.ExecuteReader();
ddlzone.DataTextField = "Regionname";
ddlzone.DataValueField = "ID";
ddlzone.DataBind();
}
}
}
Best regards
neda