i am loading xml file from url and storing data into my database.i am binding that data with my dropdownlist bt the problem is wheneverr i select any option from ddl...by defaulst it takes the always takes first selected index...i.e value at the zeroth index value.....i really don't know what exactly the problem either the problem is with dropdown or the way i am loading xml file and binding it to dropdown.....below is my cs code.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filloperator();
filldthoperator();
}
}
private void filloperator()
{
DataSet ds;
SqlDataAdapter da;
SqlConnection con;
ds = new DataSet();
con = new SqlConnection(@"Data Source=;Initial Catalog=;Integrated Security=True");
ds.ReadXml("http://letitgo.asia/api/serviceData.go?apimode=test&goid=5011000001&password=test123&rtype=xml&service_family=01");
SqlBulkCopy sbc = new SqlBulkCopy("Data Source=;Initial Catalog=;Integrated Security=True");
sbc.DestinationTableName = "r_operatorcodes";
con.Open();
sbc.WriteToServer(ds.Tables[0]);
DropDownList4.DataTextField = "operator_name";
DropDownList4.DataValueField = "operator_code";
DropDownList4.DataSource = ds;
DropDownList4.DataBind();
DropDownList4.Items.Insert(0, "-Select-");
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (DropDownList4.SelectedIndex == -1)
{
ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('select operator ');", true);
}
string op = DropDownList4.SelectedValue.ToString();
}