Devexpress DetailRow中的按钮需要两个上部嵌套APSxGridView中的键
我有两个嵌套的APSxGridView对象。内部的DetailRow还包含一个按钮。我想初始化按钮,以便它在浏览器中启动新窗口。为此,我需要上GridView中的键idDevexpress DetailRow中的按钮需要两个上部嵌套APSxGridView中的键,devexpress,master-detail,aspxgridview,Devexpress,Master Detail,Aspxgridview,我有两个嵌套的APSxGridView对象。内部的DetailRow还包含一个按钮。我想初始化按钮,以便它在浏览器中启动新窗口。为此,我需要上GridView中的键id GridView1 GridView2 DetailRow Button 我已经知道如何从GridView2获取密钥——我现有的代码如下所示: protected void btnModify_Init(object sender, EventArgs e) {
GridView1
GridView2
DetailRow
Button
我已经知道如何从GridView2获取密钥——我现有的代码如下所示:
protected void btnModify_Init(object sender, EventArgs e)
{
ASPxButton btn = sender as ASPxButton;
GridViewDetailRowTemplateContainer clsdetail = btn.Parent as GridViewDetailRowTemplateContainer;
string partition = "1"; // this should be filled with the GridView1 id
string cls = clsdetail.KeyValue.ToString(); // this is the GridView2 id
// The following code just uses the information.
string panelid = "t" + partition + "-" + cls;
btn.ClientSideEvents.Click =
String.Format("function(s, e){{ window.open('producttag.aspx?partition={0}&cls={1}','{2}'); }}",
partition, cls, panelid);
}
请注意从内部网格中获取密钥的字符串cls=…
(按钮位于其详细信息行中)
如何获取外部gridview的键?我可以通过父母再做一遍吗?或者还有别的办法吗
更新:可以在内部栅格视图中展开多个详图行。这样,我就无法通过某个隐藏元素传递id。我需要从上面的对象将其设置为按钮级别。确定。我找到了它--使用NamingContainer
:
ASPxButton btn = sender as ASPxButton;
GridViewDetailRowTemplateContainer clsdetail = btn.NamingContainer as GridViewDetailRowTemplateContainer;
Control gvClasses = clsdetail.Grid; // the grid 2
Debug.Assert(gvClasses.ClientID.EndsWith("gvClasses"));
GridViewDetailRowTemplateContainer partitionsdetail = gvClasses.NamingContainer as GridViewDetailRowTemplateContainer;
// the upper is the detail row of the grid 1
string partition = partitionsdetail.KeyValue.ToString(); // from grid 1
string cls = clsdetail.KeyValue.ToString(); // from grid 2