我用一个Datagrid控件做修改数据,在每第一次点击编辑都只刷新一下页面,再点击第二次时能出现修改的TextBox,可在在点击更新时就提示“未将对象引用设置到对象的实例。”错误,错误行的代码为:string departmentname= ((TextBox) e.Item.FindControl("部门名")).Text; 
请问这是怎么回事呀!页面:<form id="Form1" method="post" runat="server">
<P><FONT face="宋体"><asp:label id="lbldepartment" style="Z-INDEX: 101; LEFT: 240px; POSITION: absolute; TOP: 16px"
runat="server">部门列表信息</asp:label></FONT></P>
<FONT face="宋体">
<asp:datagrid id="dgdepartment" style="Z-INDEX: 102; LEFT: 104px; POSITION: absolute; TOP: 64px"
runat="server" Width="448px" Height="136px" AutoGenerateColumns="False" OnCancelCommand="dgdepartment_cancelcommand"
OnUpdateCommand="dgdepartment_updatecommand" OnEditCommand="dgdepartment_editcommand" OnDeleteCommand="dgdepartment_deletecommand"
DataKeyField="id" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" BackColor="White"
CellPadding="4">
<SelectedItemStyle   Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="部门名" HeaderText="部门名称"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="修改" CancelText="取消" EditText="编辑"></asp:EditCommandColumn>
<asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
</asp:datagrid>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
Text="Button"></asp:Button></FONT></form>后台代码: public void dgdepartment_updatecommand(object s,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int departmentid = int.Parse(dgdepartment.DataKeys[e.Item.ItemIndex].ToString());
string departmentname= ((TextBox) e.Item.FindControl("部门名")).Text; 
string sqlstr = "update 部门资料 set 部门名=@departmentnamestr where id=@departmentid";
SqlConnection myconn = new SqlConnection(ConfigurationSettings.AppSettings["connstring"]);
SqlCommand upcmd = new SqlCommand(sqlstr,myconn);
myconn.Open();
//upcmd.Parameters.Add("@departmentname",SqlDbType.NVarChar,50);
//upcmd.Parameters.Add("@departmentid",departmentid);
upcmd.Parameters.Add("@departmentnamestr",SqlDbType.NVarChar,50).Value = departmentname;
upcmd.Parameters.Add("@departmentid",departmentid).Value = departmentid;
upcmd.ExecuteNonQuery();
dgdepartment.EditItemIndex = -1;
dgdepartmentbind();
}