G
Guest
I have a dropdownlist ,for which i think the selectindexchnaged event is not
getting fired. Please help.
Thanks,
Here is the code:
public class class1: Systems.Web.UI.Page
{
//all the declarations
public void GetItems()
{
// GetConnection is a function that gets connection string and opens
the
//connection
SqlConnection myConn = GetConnection();
DataSet dsTemp;
dsTemp = new DataSet();
string strSQl ="Select name from Company";
SqlDataAdapter myAda = new SQlAdapter(strSQL,myConn);
myAda.Fill(dsTemp,"temptab");
DDLName.DataSource = dsTemp.Tables["temptab"];
DDLName.DataTextField = dsTemp.Tables["temptab"].Columns[0].ToString();
DDLName.DataValueField = dsTemp.Tables["temptab"].Columns[0].ToString();
DDLName.DataBind();
myConn.Close();
}
public void DDLName_SelectedIndexChanged(object sernder,EventArgs e)
{
lblLabel2.Text = "Event Fired" + DDLName.SelectItem.Text;
/// Do some things here like set another DDL List according to
selectedItem
}
private void Page_Load(object sender,EventArgs e)
{
DDLName.AutoPostBack = true;
DDLName.EnableViewState = false;
if(!Postback)
{
GetItems();
}
}
protected override void OnInit(EventArgs e)
{
DDLName.SelectedIndexChanged += new
EventHandler(DDLName_SelectedIndexChanged);
}
}
getting fired. Please help.
Thanks,
Here is the code:
public class class1: Systems.Web.UI.Page
{
//all the declarations
public void GetItems()
{
// GetConnection is a function that gets connection string and opens
the
//connection
SqlConnection myConn = GetConnection();
DataSet dsTemp;
dsTemp = new DataSet();
string strSQl ="Select name from Company";
SqlDataAdapter myAda = new SQlAdapter(strSQL,myConn);
myAda.Fill(dsTemp,"temptab");
DDLName.DataSource = dsTemp.Tables["temptab"];
DDLName.DataTextField = dsTemp.Tables["temptab"].Columns[0].ToString();
DDLName.DataValueField = dsTemp.Tables["temptab"].Columns[0].ToString();
DDLName.DataBind();
myConn.Close();
}
public void DDLName_SelectedIndexChanged(object sernder,EventArgs e)
{
lblLabel2.Text = "Event Fired" + DDLName.SelectItem.Text;
/// Do some things here like set another DDL List according to
selectedItem
}
private void Page_Load(object sender,EventArgs e)
{
DDLName.AutoPostBack = true;
DDLName.EnableViewState = false;
if(!Postback)
{
GetItems();
}
}
protected override void OnInit(EventArgs e)
{
DDLName.SelectedIndexChanged += new
EventHandler(DDLName_SelectedIndexChanged);
}
}