日期:2014-05-18  浏览次数:20423 次

GridView1_RowCommand 问题,提示“System.FormatException: 输入字符串的格式不正确”错误,请问哈如何解决,先谢谢了。。
protected   void   GridView1_RowCommand(object   sender,   GridViewCommandEventArgs   e)
        {          
             
                if   (e.CommandName   ==   "transfer ")  
                {
                        int   index   =   Convert.ToInt32(e.CommandArgument);
                        GridView1.SelectedIndex   =   index;
                     
                        DropDownList   drpSort   =   GridView1.Rows[index].FindControl( "droSort ")   as   DropDownList;
                        Label   lblId   =   GridView1.Rows[index].FindControl( "lblID ")   as   Label;
                        StringBuilder   sbUpdate   =   new   StringBuilder( "update   CV_Friend   set   friendsort   =   ");
                        sbUpdate.Append(drpSort.SelectedValue);
                        sbUpdate.Append( "   where   Id   =   ");
                        sbUpdate.Append(lblId.Text);

                        Response.Write(sbUpdate.ToString());
                        Response.End();
                        try
                        {
                                SqlHelper.ExecuteNonQuery(WebConfig.WWWChinavalueDbConnectionString,   CommandType.Text,   sbUpdate.ToString());
                        }
                        catch  
                        {
                                ShowClientMessegeBox( "转移失败! ");
                        }

                }
        }

------解决方案--------------------
int index = Convert.ToInt32(e.CommandArgument);
===========================================
你的按钮列必须是ButtonField