当前位置:编程学习 > C#/ASP.NET >>

在c#中怎样传递变量值

急、急在线等
protected void btnDel_Click(object sender, EventArgs e)
    {
        if (this.GridView2.Rows.Count > 0)
        {
            string str;
            PropOracleDbManager manager = new PropOracleDbManager();
            string strSql = "";
            manager.ConnectionArgs = GlobalConst.getStrCnn(1);
            manager.DatabaseType = enumDatabaseType.propDatabaseOracle;
            int num2 = this.GridView2.Rows.Count - 1;
            for (int i = 0; i <= num2; i++)
            {
                CheckBox box = (CheckBox)this.GridView2.Rows[i].Cells[0].FindControl("chkSel");
                if (box.Checked)
                {
                    string str3 = ((Label)this.GridView2.Rows[i].Cells[2].FindControl("lbSID")).Text.ToString().Trim();
                    string str4 = ((Label)this.GridView2.Rows[i].Cells[3].FindControl("Label1")).Text.ToString();
                    try
                    {
                        manager.GetConn(false);
                        strSql = "delete  from t_serviceinfo where serviceid=" + str3;
                        if (manager.ExecuteSql(strSql, "") <= 0)
                        {
                            str = "err";
                        }
                        strSql = "delete  from t_userservice where serviceid='" + str3 + "'";
                        if (manager.ExecuteSql(strSql, "") < 0)
                        {
                            str = "err";
                        }
                        GlobalConst.WriteOperationLog((GlobalConst.UserInfo)this.Session["UserInfo"], "删除[" + str4 + "]共享服务", "DQ004");
                    }
                    catch (Exception exception1)
                    {
                        ProjectData.SetProjectError(exception1);
                        Exception exception = exception1;
                        str = "err";
                        ProjectData.ClearProjectError();
                    }
                }
            }
            manager.CloseConn();
            if (str != string.Empty) 提示:使用了未赋值的局部变量str,在上面我不是已经给str变量赋值了吗,请高手指点?
            {
                this.Response.Write("<script>window.alert('删除失败,请于管理员联系!')</script>");
            }
            this.GridView2.EditIndex = -1;
            this.initBindGrid();
            DataTable dataSource = (DataTable)this.GridView2.DataSource;
            if ((dataSource == null) | (dataSource.Rows.Count == 0))
            {
                this.btnAdd_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
        }
    } --------------------编程问答-------------------- str是没有被赋值,因为可能没有执行if中的语句.可以在finally中为str赋空值. --------------------编程问答--------------------
补充:.NET技术 ,  VC.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,