Hi, I have been working with my project for 2 weeks but i have failed everytime, The problem is i want to catch the selecteditem in my dropdownlist but it is just the first item everytime,
here is my code:
protected override void CreateChildControls()
{
DDL = new DropDownList();
DDL.Load += new EventHandler(DDLLoad);
DDL.SelectedIndexChanged += new EventHandler(DDLItemChanged);
Controls.Add(DDL);
}
protected void DDLLoad(object sender, EventArgs e)
{
DS = GetChannels();
if (DS.Tables.Count > 0 )
{
DDL.DataSource = DS;
DDL.DataTextField = "title";
DDL.DataValueField = "title";
DDL.DataBind();
}
else
{
MessageLBL.Text = "Unable to connect to the database.";
}
}
protected void DDLItemChanged(object sender, EventArgs e)
{
string mytitle = DDL.SelectedValue;
MessageLBL.Text = mytitle; //here it is always the first item
}
here is my code:
protected override void CreateChildControls()
{
DDL = new DropDownList();
DDL.Load += new EventHandler(DDLLoad);
DDL.SelectedIndexChanged += new EventHandler(DDLItemChanged);
Controls.Add(DDL);
}
protected void DDLLoad(object sender, EventArgs e)
{
DS = GetChannels();
if (DS.Tables.Count > 0 )
{
DDL.DataSource = DS;
DDL.DataTextField = "title";
DDL.DataValueField = "title";
DDL.DataBind();
}
else
{
MessageLBL.Text = "Unable to connect to the database.";
}
}
protected void DDLItemChanged(object sender, EventArgs e)
{
string mytitle = DDL.SelectedValue;
MessageLBL.Text = mytitle; //here it is always the first item
}