1
Reply

Fatch data from database to Checkbox List ON Select

jitendra gupta

jitendra gupta

Apr 9 2015 2:12 AM
597
I have 3 levels of selection.
In the first level have to disply all the Country in a check box list from the database.
The user is allowed to select any number of Countries and based on those selections
I have to show the States which comes under each Countries in seperate checkbox lists.
The user is allowed to select any number of States and based on these selections
I have to show the disttric of each selected States.
please help to solve it.
 i am using following code but its not work proper 
 
MySqlConnection con;
con = new MySqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
con.Open();
try
{
for (int i = 0; i < CblistForPravilage.Items.Count; i++)
{
if (CblistForPravilage.Items[i].Selected)
{
string var = string.Empty;
var += CblistForPravilage.Items[i].Value.ToString();
string str = "SELECT * FROM add_state where CID='" + var + "'";
MySqlCommand cmd;
cmd = new MySqlCommand(str, con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
CblistForPravilage0.DataSource = ds;
CblistForPravilage0.DataTextField = "SName";
CblistForPravilage0.DataValueField = "SID";
CblistForPravilage0.DataBind();
}
}
}
}
catch
{
}
}
 
 
 
 

Answers (1)