Click here to Skip to main content
16,012,316 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Problem with gridview Pin
Abhijit Jana11-Jan-09 19:00
professionalAbhijit Jana11-Jan-09 19:00 
AnswerRe: Problem with gridview Pin
Anshumas11-Jan-09 22:22
Anshumas11-Jan-09 22:22 
AnswerRe: Problem with gridview Pin
goodideadave13-Jan-09 13:51
goodideadave13-Jan-09 13:51 
QuestionChanging the Language of windows through asp.net Pin
Mr.Sam11-Jan-09 7:08
Mr.Sam11-Jan-09 7:08 
AnswerRe: Changing the Language of windows through asp.net Pin
Christian Graus11-Jan-09 16:39
protectorChristian Graus11-Jan-09 16:39 
GeneralRe: Changing the Language of windows through asp.net Pin
Not Active11-Jan-09 16:58
mentorNot Active11-Jan-09 16:58 
GeneralRe: Changing the Language of windows through asp.net Pin
Christian Graus12-Jan-09 0:08
protectorChristian Graus12-Jan-09 0:08 
QuestionHow to handle event in two user control dropdown list. Pin
Rajesh_K_Sharma11-Jan-09 2:06
Rajesh_K_Sharma11-Jan-09 2:06 
Dear friends,
I am trying to create two dropdown list user controls and these are dependent on each other like state is dependent on country. When I select county then I am unable to fill state dropdown. How can I fill state dropdown on selection of country?
I have followed steps like this

Country.ascx:-

]]>
<asp:dropdownlist id="ddlCountry" runat="server" xmlns:asp="#unknown">


Code behind:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Country : System.Web.UI.UserControl
{
public event EventHandler SelectedIndexChanged;
public string SelectedValue
{
get
{
return Convert.ToString(ViewState["Value"]);
}
set
{
ViewState["Value"] = value;
}
}

public bool AutoPostBack
{
get { return Convert.ToBoolean(ViewState["AutopostBack"]); }
set { ViewState["AutopostBack"] = value; }

}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlCountry.Items.Insert(0, new ListItem ( "India","0"));
ddlCountry.Items.Insert(1, new ListItem ("South Korea","1"));

}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ddlCountry.AutoPostBack = true;
ddlCountry.SelectedIndexChanged += new EventHandler(ddlCountry_SelectedIndexChanged);
}

void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
OnSelectedIndexChanged(e);

}


protected void OnSelectedIndexChanged(EventArgs e)
{
if (SelectedIndexChanged != null)
{

SelectedValue = ddlCountry.SelectedValue.ToString();
SelectedIndexChanged(this, e);
}
}

}

State.ascx

<asp:dropdownlist id="ddlState" runat="server" xmlns:asp="#unknown">



public partial class State : System.Web.UI.UserControl
{
public string CountrySelectedValue
{
get { return Convert.ToString(ViewState["Id"]); }
set { ViewState["Id"] = value; }

}

protected void Page_Load(object sender, EventArgs e)
{
switch (CountrySelectedValue)
{
case "0":
ddlState.Items.Add("Delhi");
ddlState.Items.Add("MP");

break;
case "1":
ddlState.Items.Add("Sunae");
ddlState.Items.Add("Seoul");
break;
default:
ddlState.Items.Add("Select");
break;


}

}
}

Default.aspx




<uc1:country id="Country1" runat="server" xmlns:uc1="#unknown">
<uc2:state id="State1" runat="server" xmlns:uc2="#unknown">


protected void Page_Load(object sender, EventArgs e)
{
Country1.SelectedIndexChanged +=new EventHandler(Country1_SelectedIndexChanged);
}

void Country1_SelectedIndexChanged(object sender, EventArgs e)
{
//throw new NotImplementedException();

State1.CountrySelectedValue = Country1.SelectedValue;

}
I want to fill state dropdwon on selction on country. How can I do this?
Please help me.


Regrads
Rajesh

rajesh

AnswerRe: How to handle event in two user control dropdown list. Pin
Aman Bhullar11-Jan-09 4:06
Aman Bhullar11-Jan-09 4:06 
GeneralRe: How to handle event in two user control dropdown list. Pin
Not Active11-Jan-09 4:39
mentorNot Active11-Jan-09 4:39 
GeneralRe: How to handle event in two user control dropdown list. Pin
Christian Graus11-Jan-09 4:51
protectorChristian Graus11-Jan-09 4:51 
GeneralRe: How to handle event in two user control dropdown list. Pin
Aman Bhullar11-Jan-09 5:54
Aman Bhullar11-Jan-09 5:54 
GeneralRe: How to handle event in two user control dropdown list. Pin
Rajesh_K_Sharma11-Jan-09 6:41
Rajesh_K_Sharma11-Jan-09 6:41 
GeneralRe: How to handle event in two user control dropdown list. Pin
Not Active11-Jan-09 8:18
mentorNot Active11-Jan-09 8:18 
GeneralRe: How to handle event in two user control dropdown list. Pin
Not Active11-Jan-09 8:15
mentorNot Active11-Jan-09 8:15 
GeneralRe: How to handle event in two user control dropdown list. Pin
Aman Bhullar11-Jan-09 17:49
Aman Bhullar11-Jan-09 17:49 
GeneralRe: How to handle event in two user control dropdown list. Pin
Not Active11-Jan-09 18:13
mentorNot Active11-Jan-09 18:13 
AnswerRe: How to handle event in two user control dropdown list. Pin
Not Active11-Jan-09 4:10
mentorNot Active11-Jan-09 4:10 
AnswerRe: How to handle event in two user control dropdown list. Pin
Anshumas11-Jan-09 22:43
Anshumas11-Jan-09 22:43 
Question[Message Deleted] Pin
Rohan Rajpoot11-Jan-09 0:36
Rohan Rajpoot11-Jan-09 0:36 
AnswerRe: datagrid problem! Pin
Abhijit Jana11-Jan-09 1:01
professionalAbhijit Jana11-Jan-09 1:01 
AnswerRe: [Message Deleted] Pin
Abhijit Jana11-Jan-09 1:11
professionalAbhijit Jana11-Jan-09 1:11 
QuestionIFrame Problem Pin
ais0711-Jan-09 0:15
ais0711-Jan-09 0:15 
AnswerRe: IFrame Problem Pin
Aman Bhullar11-Jan-09 0:58
Aman Bhullar11-Jan-09 0:58 
AnswerRe: IFrame Problem Pin
Abhijit Jana11-Jan-09 0:58
professionalAbhijit Jana11-Jan-09 0:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.