【发布时间】:2014-05-02 05:49:34
【问题描述】:
我想知道如何从网格加载会话数据并将其传递到
下拉列表的下一页并将其保存在数据库中。
例如:我在第 1 页名称、地址、国家/地区的网格数据
protected void PassData(object sender, EventArgs e)
{
GridViewRow gr = ((sender as LinkButton).NamingContainer as GridViewRow);
Session["Name"] = gr.Cells[3].Text.Trim();
Session["Address"] = gr.Cells[4].Text.Trim();
Session["Country"] = gr.Cells[5].Text.Trim();
}
我正要在第 2 页的 Country 下拉列表中加载 Country 值。
我的下拉列表具有预加载的国家/地区列表,我必须加载
我在我的 Session[“Country”] 中拥有的国家/地区值。
例如:
CountryID Country
1 USA
2 AUSTRALIA
3 CHINA
所以我使用了代码..
ddlCountry.SelectedItem.Text = Session["Country"].ToString();
在我的页面加载中加载国家列表
private void BindCountry()
{
DataTable dt = new DataTable();
dt = objUser.SelAllCountry();
objCommon.BindDropDown(ddlCountry, "CountryID", "CountryName", dt);
ddlCountry.SelectedValue = "1";
}
ddlCountry.SelectedItem.Text=我的会话值存在于其中,但是 无法将其存储在我的数据库中..
int country
objCustomer.Country = int.Parse(ddlCountry.SelectedValue);//state to pass the country value.. i know its wrong i need help over here to save my data.
我无法保存新值,它始终显示默认值 1 USA
页面加载
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCountry();
//BindState(1);
}
}
谁能帮我解决这个问题.. 谢谢-提前..
【问题讨论】:
-
向我们展示您的 Page_load() 事件代码