protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
//绑定所属区域;
SqlConnection myconnection = new SqlConnection(sqlconn);
SqlCommand mycommand = new SqlCommand("iDCIDConvert", myconnection);
mycommand .CommandType =CommandType .StoredProcedure ;
mycommand.Parameters.Add(new SqlParameter("@iDCID", SqlDbType.Int, 4));
if (e.Row.RowType == DataControlRowType.DataRow)
{
HiddenField hfd1 = (HiddenField)e.Row.FindControl("HiddenField1");
int iDCIDTemp =Convert.ToInt32 ( hfd1.Value);
mycommand.Parameters["@iDCID"].Value = iDCIDTemp;
myconnection.Open();
SqlDataAdapter da = new SqlDataAdapter(mycommand);
DataSet ds = new DataSet();
DropDownList ddl1 = (DropDownList)e.Row.FindControl("DropDownList1");
da.Fill(ds, "basic_DistrictClass");
ddl1.DataSource = ds.Tables["basic_DistrictClass"].DefaultView;
ddl1.DataTextField = "cDCName";
ddl1.DataValueField = "iDCID";
ddl1.DataBind();
myconnection.Close();
}
}-----------------------------------------------------------------------------
错误:int iDCIDTemp =Convert.ToInt32 ( hfd1.Value); “输入字符串的格式不正确。”
{
//绑定所属区域;
SqlConnection myconnection = new SqlConnection(sqlconn);
SqlCommand mycommand = new SqlCommand("iDCIDConvert", myconnection);
mycommand .CommandType =CommandType .StoredProcedure ;
mycommand.Parameters.Add(new SqlParameter("@iDCID", SqlDbType.Int, 4));
if (e.Row.RowType == DataControlRowType.DataRow)
{
HiddenField hfd1 = (HiddenField)e.Row.FindControl("HiddenField1");
int iDCIDTemp =Convert.ToInt32 ( hfd1.Value);
mycommand.Parameters["@iDCID"].Value = iDCIDTemp;
myconnection.Open();
SqlDataAdapter da = new SqlDataAdapter(mycommand);
DataSet ds = new DataSet();
DropDownList ddl1 = (DropDownList)e.Row.FindControl("DropDownList1");
da.Fill(ds, "basic_DistrictClass");
ddl1.DataSource = ds.Tables["basic_DistrictClass"].DefaultView;
ddl1.DataTextField = "cDCName";
ddl1.DataValueField = "iDCID";
ddl1.DataBind();
myconnection.Close();
}
}-----------------------------------------------------------------------------
错误:int iDCIDTemp =Convert.ToInt32 ( hfd1.Value); “输入字符串的格式不正确。”
解决方案 »
- 用 iTextSharp 5 如何让表格中的单元格能跨页
- 提供播放器源码
- 在 UpdatePanel 中的 FCKeditor ,在第一次提交的时候还好使,可是在第二次提交的时候获得的FCKeditor 1.value就总是""(空)了??
- 为什么会出现这个错误 ?分析器错误信息: 无法识别的属性“restartOnExternalChanges”
- 如何页面无刷新
- C# ASP.NET 多语言网站 解决方案
- (极初级问题)有微软工程师吗?问个给客户上项目用sqlserver的问题。
- 问个简单问题,大家帮我下
- 确定传输完毕问题?
- asp.net配置问题
- 一简单正则表达式的错误
- 重定向 URI 不能包含换行符
//////////
在那里设个断点,看看读到的hfd1.Value的值是什么.
{}事件中问题解决了;
在GridView1_RowCreated事件中HiddenField还未绑定值,所以.....