调试时 输入字符串的格式不正确
Stack Trace:System.FormatException: 输入字符串的格式不正确。 在 System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) 在 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) 在 System.Convert.ToInt32(String value) 在 qminoa.Webs.PM.UserList.Users_UpdateCommand(Object source, GridViewUpdateEventArgs e) 位置 E:\C20-C26办公自动化系统\PM\UserList.aspx.cs:行号 125 在 System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) 在 System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) 在 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) 在 System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) 在 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) 在 System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) 在 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) 在 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) 在 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) 在 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) 在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) 在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
求指教啊 --------------------编程问答-------------------- 断点下撒 --------------------编程问答-------------------- 贴点代码。自己调试,提示的很清楚 --------------------编程问答-------------------- 在哪里设断点啊? --------------------编程问答-------------------- 代码是:
protected void Users_UpdateCommand(object source, GridViewUpdateEventArgs e)
{
GridViewRow myrow = Users.Rows[e.RowIndex];
int _userid;
int _roleid;
//得到人员RowIndex
_userid = Convert.ToInt32(Users.DataKeys[e.RowIndex].ToString());
//得到项目角色ID
DropDownList currentRoleNameList = (DropDownList)myrow.FindControl("ddlRoles");
_roleid = Convert.ToInt16(currentRoleNameList.SelectedItem.Value);
//更新人员项目角色
PMUser.UpdateUserRole(_userid,_roleid);
Users.EditIndex = -1;
//重新绑定
LoadUsers();
}
protected void Users_CancelCommand(object source, GridViewCancelEditEventArgs e)
{
Users.EditIndex = -1;
LoadUsers();
}
protected void Users_ItemDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Insert)
{
DropDownList currentRoleNameList = (DropDownList) e.Row.FindControl("ddlRoles");
currentRoleNameList.SelectedIndex = currentRoleNameList.Items.IndexOf(currentRoleNameList.Items.FindByText(temp_rolename));
}
}
private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
{
AdminDB admin = new AdminDB();
DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
DepartmentDropList.DataBind();
if(DepartmentDropList.Items.Count !=0)
{
Users.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
Users.DataBind();
}
else
{
Users.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,0);
Users.DataBind();
}
}
private void DepartmentDropList_SelectedIndexChanged(object sender, System.EventArgs e)
{
Users.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
Users.DataBind();
}
string SortField
{
get
{
object o = ViewState["SortField"];
if (o == null)
return string.Empty;
return (string)o;
}
set
{
if (value == SortField)
SortAscending = !SortAscending;
ViewState["SortField"] = value;
}
}
bool SortAscending
{
get
{
object o = ViewState["SortAscending"];
if (o == null)
return true;
return (bool)o;
}
set
{
ViewState["SortAscending"] = value;
}
}
}
}
--------------------编程问答-------------------- 你在哪里取的“你输入的这个值“ 就在那里打个断点 --------------------编程问答-------------------- 行号是125的代码是: _userid = Convert.ToInt32(Users.DataKeys[e.RowIndex].ToString());
--------------------编程问答-------------------- Users.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
是这行出错吗?打个断点看看DepartmentDropList.SelectedItem.Value是不是整型的字符串嘛??
补充:.NET技术 , ASP.NET