public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
nsBll.CouBll pBAL = new nsBll.CouBll();
List
lstcountry.DataSource = dataSource;
lstcountry.DataTextField = "p_counam";
lstcountry.DataValueField = "p_coucod";
lstcountry.DataBind();
}
protected void lstcountry_SelectedIndexChanged(object sender, EventArgs e)
{
string qry = "select * from tbl_office where countrycode = '" + lstcountry.SelectedValue + "'";
SqlDataAdapter da = new SqlDataAdapter(qry, ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
DataSet ds = new DataSet();
da.Fill(ds);
grdlocation.DataSource = ds;
grdlocation.DataBind();
}
}
In List coountry country names are displayed like Australia , India & their codes are AU,IN. what i have written in lstcountry_selectedindexchanged it does not show any record in Gridvew .
Thanks
Amit ChoudharyPosted Jul 21, 2011, 7:30 AM
Better you put the code in Page_load in if(!Page.IsPostBack){} block.
hope this helped you.