数据未在页面加载事件上加载 [英] data not loading on page load event

查看:86
本文介绍了数据未在页面加载事件上加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份报名表。我已经制作了级联下拉列表,其中状态下拉列表的数据被加载到国家的选定索引更改。 sql数据库有表Country和State。



我正在加载所有数据(其他页面,就像这里是编辑配置文件),这是在各个文本框和下拉列表中的页面加载事件的注册期间提交的。问题是国家在国家下拉菜单上完全加载,但各州的价值没有在州下降时加载。





code我使用的如下所示



I have one registration form. I have made cascading dropdownlist in which data of state dropdownlist is loaded on selected index change of Country. sql database is having table Country and State.

I am loading all data(other page, like here it is edit profile) which was submitted during registration on page load event at respective textboxes and dropdownlist. The problem is that Country is loading perfectly on country dropdown but the value of respective state is not loading on state drop down.


code that i am using is as below

protected void loadinternshipdata()
       {
           SqlConnection con = new SqlConnection("Data Source=ja-pc\\sqlexpress;Initial Catalog=Internship;Integrated Security=True;Pooling=False");

           con.Open();
           SqlCommand cmd3 = new SqlCommand("select * from Internship where CompanyID=" + Convert.ToInt16(Session["CompanyID"].ToString()), con);

           SqlDataAdapter daa = new SqlDataAdapter(cmd3);
           DataTable dtt = new DataTable();
           daa.Fill(dtt);
           if (dtt.Rows.Count > 0)
           {

               DropDownList3.SelectedItem.Text = dtt.Rows[0]["Country"].ToString();
              DropDownList4.SelectedItem.Text = dtt.Rows[0]["State"].ToString();







           }
       }

推荐答案

嗯尝试这个:

Mmmm try this:
protected void loadinternshipdata()
{
    if (!IsPostBack)
    {
        //YOUR CODE HERE.
    }
}





希望有所帮助。



Hope it helps.


这篇关于数据未在页面加载事件上加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆