GridView如何在编辑状态下取得控件的值?
        <asp:TemplateField HeaderText="社员组" >
            <EditItemTemplate>
                <asp:DropDownList ID="ddlgv社员组" runat="server" Width="100px" DataSourceID="sds社员组" DataTextField="组名" DataValueField="组号"></asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate >
                <asp:Label ID="lblgv社员组" runat="server" Text="" Visible="false"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="社员号">
            <EditItemTemplate>
                <asp:TextBox ID="txtgv社员号" runat="server" Text='<%# Bind("社员号") %>' Width="50px"></asp:TextBox>
                <asp:HyperLink ID="jobname" runat="server" NavigateUrl="" Target=_blank Text="社员选择" ForeColor="blue" Font-Underline="true" onMouseOver="this.style.cursor='hand'"></asp:HyperLink>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="lblgv社员号" runat="server" Text='<%# Bind("社员号") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
上面是GridView中的2个列,最终想做到点击GridView的“编辑”按钮时,选择某个社员组,
然后点击“社员选择”链接时,弹出该社员组的全部社员的GridView的小窗口,选择某个社员后将该社员的号码
赋值到父窗口的文本框里。可能比较难,也说的不清楚,不好意思,呵呵。看得懂得人有知道怎么实现的吗?

解决方案 »

  1.   

    得到你当前编辑行的rowIndex通过 
    社员组: (DropDownList)grid.rows[rowIndex].Cells[列的索引1].Controls[0]
    社员号: (TextBox)grid.rows[rowIndex].Cells[列的索引2].Controls[0]
    社员选择: (TextBox)grid.rows[rowIndex].Cells[列的索引2].Controls[1]----------
    其实FindControl也行
      

  2.   

    ((TextBox)GridData.Rows[e.RowIndex].FindControl("txtgv社员号")).Text;
    ((DropDownList)GridData.Rows[e.RowIndex].FindControl("ddlgv社员组")).SelectedValue;
      

  3.   


        protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.RowState == DataControlRowState.Edit)  // 奇数行
            if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)  // 全部行
            {
                TextBox txtAAA = (TextBox)e.Row.FindControl("txtgv社員号");  // 能找到该控件
                string strTest = txtAAA.Text;  // 可是值却为空。而明明点完编辑按钮后社员号文本框是有值的,我现在不知道如何得到社员号文本框的值            DropDownList ddlAAA = (DropDownList)e.Row.FindControl("ddlgvグループコード1");
                string strTest2 = ddlAAA.SelectedValue;            HyperLink zlluClick = (HyperLink)e.Row.FindControl("jobname"); // 能找到该控件
                zlluClick.Attributes.Add("onclick", "window.open('testDetail.aspx','','width=400,height=200,toolbar=no,menubar=no,scrollbars=no')"); 
            }
        }
      

  4.   

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            DropDownList t = GridView1.Rows[e.NewEditIndex].FindControl("ddlgv社员组") as DropDownList;
            string value = t.SelectedValue;
        }
      

  5.   

    应该可以在原页面通过JavaScript调用子页面,在子页面选择后将选择的值通过Javascript传到原页面,原页面也通过JavaScript将该值赋给文本框!
      

  6.   

    点击的链接调用
    function getMedicine()
    {            
        var med=new Array();            
        med=window.showModalDialog("新页面名","Medicine","help=no;dialogWidth:800px;dialogHeight:500px;scroll:no");
        if(med)
        {
            $get("hdfMedId").innerText=med[0];
            $get("txtQuantity").focus();               
        }           
    }子窗口选择后调用
     function getRowValue(selrow)
    {            
        var RowCells=new Array();
        RowCells[0]=selrow.getAttribute('guid');            
        RowCells[1]=selrow.cells[0].innerText;    var ua = navigator.userAgent;
        var ie = navigator.appName == "Microsoft Internet Explorer" ? true:false;  
        if (ie) 
        { 
            var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))));
            if (IEversion< 5.5) 
            { 
                var str  = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'; 
                str += '<param name="Command" value="Close"></object>'; 
                document.body.insertAdjacentHTML("beforeEnd", str); 
                document.all.noTipClose.Click();
            }    
            window.returnValue = RowCells;    
        } 
        else 
        { 
            window.opener.inserObject(null,'mod',RowCells);  
        } 
        window.opener=null;
        window.close();                     
    }
    直接关闭页面并传回选择的值!仅供参考!
      

  7.   


    ((YourControlType)GridView1.FindControl("YourControlName")).value