2011-12-15 46 views
0

如何为SharePoint对话框添加值以绑定数据? 我所说的对话框这样如何为SharePoint对话框添加值以绑定数据?

<input type="button" value="<%#((DataRowView)Container.DataItem)["Id"] %>" onclick="javascript:Open()" /> 

脚本

<script type="text/javascript"> 
    //User Defined Function to Open Dialog Framework 
    function Open() { 

     var strPageURL = '<%= ResolveClientUrl("~/View.aspx") %>'; 
     OpenCustomDialogWithRefresh(strPageURL, 650, 400, "Add Document Type"); 
     return true; 
    } 
</script> 

JS

function OpenCustomDialogWithRefresh(dialogUrl, dialogWidth, dialogHeight, dialogTitle, dialogAllowMaximize, dialogShowClose) { 

var options = { 
    url: dialogUrl, 
    allowMaximize: dialogAllowMaximize, 
    showClose: dialogShowClose, 
    width: dialogWidth, 
    height: dialogHeight, 
    title: dialogTitle, 
    dialogReturnValueCallback: Function.createDelegate(null, CloseCallback4) 
}; 
SP.UI.ModalDialog.showModalDialog(options);} 

我不知道如何把ID值到View.aspx。

然后我可以在view.aspx页面中填充数据。

在此先感谢。

回答

1

您可以将ID作为查询字符串参数传递。这将使你的URL行是这样的:

var strPageURL = "<%= String.Format("{0}?id={1}", 
        ResolveClientUrl('~/View.aspx'), 
        ((DataRowView)Container.DataItem)['Id']) %>"; 

给你一个网址,看起来像

mysite.com/View.aspx?id=12345 

然后view.aspx你应​​该能够抓住查询字符串“ID”键的值。

更新:

如果您使用此行就像在你的例子:

OpenCustomDialogWithRefresh(strPageURL, 650, 400, "Add Document Type"); 

,你应该能够访问在回发的查询字符串PARAM:

if (Page.IsPostBack) 
{ 
    string id = Request.QueryString["id"]; 
    // use the id here 
} 
+0

VAR strPageURL ...应该是在GridView? – kevin 2011-12-15 03:02:29

0

这是我尝试和解决的方式。

它在GridView

<input type="button" value="<%#((DataRowView)Container.DataItem)["DocTypeCode"] %>" onclick="javascript:Open('<%#Eval("Id") %>')" /> 

它是JavaScript

function Open(id) { 
    var strPageURL = '<%= ResolveClientUrl("~/_layouts/RPSWA/Dialogs/DocTypeView.aspx?id=") %>' + id; 
相关问题