小弟在写一个项目的时候用了一个三层架构,就是逻辑层和页面完全分离的
但是现在取girdview里面的控件值的时候,一直要使用到前台的代码
我是使用如下的方法去取girdview里面控件值的 
                    Dim myRec_Date As New TextBox
                    Dim myIfs_Po_Rec_No As New TextBox
                    Dim myRm_Part_No As New TextBox
                    Dim myRm_Part_Type As New TextBox
                    Dim myRm_Furn_No As New TextBox
                    Dim myRec_Area As New TextBox
                    Dim myRec_Kg As New TextBox
                    Dim myRec_Thk As New TextBox
                    Dim myPut_Location As New TextBox
                    '从GridView中取出控件
                    myRec_Date = dtrow.Cells(0).FindControl("TextBox1")
                    myIfs_Po_Rec_No = dtrow.Cells(1).FindControl("TextBox2")
                    myRm_Part_No = dtrow.Cells(2).FindControl("TextBox3")
                    myRm_Part_Type = dtrow.Cells(3).FindControl("TextBox4")
                    myRm_Furn_No = dtrow.Cells(4).FindControl("TextBox5")
                    myRec_Area = dtrow.Cells(5).FindControl("TextBox6")
                    myRec_Kg = dtrow.Cells(6).FindControl("TextBox7")
                    myRec_Thk = dtrow.Cells(7).FindControl("TextBox8")
                    myPut_Location = dtrow.Cells(8).FindControl("TextBox9")这样就会出现一个困然,如果我girdview的前台界面的控件ID有改变的话,我整个逻辑层就错误了
有没有什么好的办法,直接可以去girdview里面的控件值,而不用管gridview里面究竟是放的什么控件

解决方案 »

  1.   


    求解释啊 
    貌似我现在就是用的定义数组哦   
    我还是要从gridview中取值给数组赋值的哦
      

  2.   

    你的控件不应该放在逻辑层吧。如果非要这么做,你可以采用这样的方法
    myRec_Date = CType( dtrow.Cells(0).Controls(0),TextBox)Controls(0)
    还是
    Controls(1)根据内容决定
      

  3.   


    您说的对啊   我的控件是不应该放到逻辑层
    但是我现在的做法   是在逻辑层用到控件了  
    有没有什么方法  我在逻辑层不用到任何控件 
    就能取到gridview里面的值
      

  4.   

    提交的话你也可以直接在按钮的 OnClick事件里去写逻辑代码。。实质上是把表单数据提交给自己做响应处理了。