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的小窗口,选择某个社员后将该社员的号码
赋值到父窗口的文本框里。可能比较难,也说的不清楚,不好意思,呵呵。看得懂得人有知道怎么实现的吗?
<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的小窗口,选择某个社员后将该社员的号码
赋值到父窗口的文本框里。可能比较难,也说的不清楚,不好意思,呵呵。看得懂得人有知道怎么实现的吗?
解决方案 »
- 相关弹出框插件
- 冰天雪地裸体360度50分跪求一个能支持图片和FLASH的广告控件!
- 怎样获取访问者的IP,IE版本号,计算机名.
- 弹出确定取消框, 如何把‘来自网页的消息’换掉
- 关于TreeView问题
- 高分求属性页
- 求webservice.htc组件,微软的网站没有了。谁能给我一个其他的链接?救命!
- js问题。
- 解决VS.NET 2003正式版在Windows Server 2003 3790域控制器上不能执行的问题!
- 头痛的问题,我想LinkButton提交后整个页面不用刷新,这样javascript附的值才不会被丢,有什么办法?
- 谁有《ASP.NET2.0开发与指南》电子书的下载地址,分享下
- 关于在.net网页里面挂漂浮广告的问题!
社员组: (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也行
((DropDownList)GridData.Rows[e.RowIndex].FindControl("ddlgv社员组")).SelectedValue;
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')");
}
}
{
DropDownList t = GridView1.Rows[e.NewEditIndex].FindControl("ddlgv社员组") as DropDownList;
string value = t.SelectedValue;
}
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();
}
直接关闭页面并传回选择的值!仅供参考!
((YourControlType)GridView1.FindControl("YourControlName")).value