2010-05-17 51 views
0

我有一個從用戶控件呈現的SharePoint分頁自定義頁面應用程序。在用戶控制頁面中,我使用了SPGridview來顯示數據。我的第一列是標題欄(鏈接按鈕欄),當用戶點擊鏈接時,一個彈出窗口將打開相應的數據。但問題是鏈接按鈕無法正常工作。但是這個應用程序在asp.net應用程序中工作得很好。SP Gridview鏈接按鈕列不能正常工作

我的代碼如下所示..

<asp:UpdatePanel runat="server" ID="UpdatePanel2"> 
              <ContentTemplate> 
               <SharePoint:SPGridView ID="dgApplicationBox" CellPadding="0" Height="100%" runat="server" 
                ForeColor="Black" Font-Size="10px" Font-Names="Verdana" AutoGenerateColumns="False" 
                AllowPaging="True" Width="100%" BorderStyle="None" BorderWidth="0px" PageSize="10" 
                BorderColor="White" BackColor="White" OnRowDataBound="dgApplicationBox_RowDataBound" 
                DataKeyNames="ApplicationID" OnSelectedIndexChanged="dgApplicationBox_SelectedIndexChanged" 
                OnPageIndexChanging="dgApplicationBox_PageIndexChanging" CssClass="ms-listviewtable" 
                AlternatingRowStyle-CssClass="ms-alternating"> 
                <SelectedRowStyle Font-Bold="True" ForeColor="Black" BackColor="#CE5D5A"></SelectedRowStyle> 
                <EditRowStyle Font-Size="10px" Font-Names="Verdana,Arial,Helvetica,sans-serif"></EditRowStyle> 
                <HeaderStyle Font-Size="11px" Height="20px" Font-Bold="True" ForeColor="Black" BackColor="#E7E8EC"> 
                </HeaderStyle> 
                <PagerStyle HorizontalAlign="Center" ForeColor="#414E61" Font-Size="5px" Font-Names="arial" 
                 Height="10px" BackColor="#EBF3FF"></PagerStyle> 
                <RowStyle /> 
                <Columns> 
                 <asp:TemplateField HeaderText="Title" HeaderStyle-CssClass="ms-vb"> 
                  <ItemTemplate> 
                   <asp:LinkButton ID="lbtnSubject" 
                    Text='<%# Bind("UDF5") %>' runat="server" OnClick="lbtnSubject_Click"></asp:LinkButton> 
                  </ItemTemplate> 
                  <HeaderStyle HorizontalAlign="Left" CssClass="ms-vh2" Font-Bold="true" /> 
                  <ItemStyle HorizontalAlign="Left" CssClass="ms-vb2" /> 
                 </asp:TemplateField> 
                 <asp:TemplateField HeaderText="Request No."> 
                  <ItemTemplate> 
                   <asp:Label ID="lblReqNo" Text='<%# Bind("UDF1") %>' runat="server" /> 
                  </ItemTemplate> 
                  <HeaderStyle HorizontalAlign="Left" CssClass="ms-vh2" Font-Bold="true" /> 
                  <ItemStyle HorizontalAlign="Left" CssClass="ms-vb2" /> 
                 </asp:TemplateField> 
                 <asp:BoundField DataField="CreatedOn" HeaderText="Created On" DataFormatString="{0:MM/dd/yyyy}" 
                  HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> 
                  <HeaderStyle CssClass="ms-vh2" Font-Bold="true"></HeaderStyle> 
                  <ItemStyle CssClass="ms-vb2"></ItemStyle> 
                 </asp:BoundField> 
                 <asp:BoundField DataField="Name" HeaderText="Form Type" HeaderStyle-HorizontalAlign="Left" 
                  ItemStyle-HorizontalAlign="Left"> 
                  <HeaderStyle CssClass="ms-vh2" Font-Bold="true"></HeaderStyle> 
                  <ItemStyle CssClass="ms-vb2"></ItemStyle> 
                 </asp:BoundField> 
                 <asp:TemplateField HeaderText="History"> 
                  <HeaderStyle CssClass="ms-vh2" Font-Bold="true"></HeaderStyle> 
                  <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="21px" CssClass="ms-vb2"> 
                  </ItemStyle> 
                  <ItemTemplate> 
                   <asp:LinkButton ID="lbtnView" runat="server" OnClick="lbtnView_Click" >View</asp:LinkButton> 
                  </ItemTemplate> 
                 </asp:TemplateField> 
                 <asp:TemplateField HeaderText="Application Id" Visible="False"> 
                  <ItemTemplate> 
                   <asp:Label ID="lblApplicationId" runat="server" Text='<%# Bind("ApplicationId") %>'></asp:Label> 
                  </ItemTemplate> 
                  <HeaderStyle HorizontalAlign="Left" CssClass="ms-vh2" Font-Bold="true" /> 
                  <ItemStyle HorizontalAlign="Left" CssClass="ms-vb2" /> 
                 </asp:TemplateField> 
                </Columns> 
               </SharePoint:SPGridView> 
              </ContentTemplate> 
             </asp:UpdatePanel> 

當鏈接按鈕,用戶點擊,這段代碼將工程..

try 
      { 
       clearSession(); 
       Session["DigitalSignature"] = null; 
       Button btnDetails = sender as Button; 
       DataTable dt = (DataTable)dgApplicationBox.DataSource; 
       GridViewRow gvRow = (GridViewRow)(sender as LinkButton).Parent.Parent; 
       Session["AppId"] = ((Label)gvRow.FindControl("lblApplicationId")).Text; 
       string subject = ((LinkButton)gvRow.FindControl("lbtnSubject")).Text; 


       WFInfo objWFInfo = new WFInfo(); 
       objWFInfo.InitWorkflowProperty(Convert.ToInt32(Session["AppId"].ToString()), Session["CurrentUser"].ToString()); 
       Session["FormId"] = objWFInfo.FormID.ToString(); 

       string strFilname = objWFInfo.GetFormName(objWFInfo.ApplicationCategoryID.ToString()); 
       string WindowName = strFilname; 
       strFilname += ".aspx"; 
       Session["CategoryId"] = objWFInfo.ApplicationCategoryID.ToString(); 
       //pnlSubmitModal_ModalPopupExtender.Show(); 

       ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "popUpWindow('" + strFilname + "?tittle=" + subject + "', 800, 690,'" + WindowName + "');", true); 

       this.Controls.Add(new LiteralControl("<script>alert('hi');</script>")); 

       if (Session["CurrentUser"] != null) 
       { 
        ApplicationForm objApplication = new ApplicationForm(); 
        objApplication.markRead(Convert.ToInt32(Session["AppId"].ToString()), Session["CurrentUser"].ToString()); 

       } 
       bindFolderData(); 
      } 

如果我的鏈接點擊鏈接,就會出現只能發回。但不彈出窗口打開..請幫我解決這個問題。在此先感謝..

回答

1

你檢查,看看你是否收到一個JavaScript錯誤的點擊?

您是否嘗試過設置UpdatePanel2的UpdateMode =「Conditional」,然後添加觸發器? (點擊按鈕)

喜歡這個樣本:

</ContentTemplate> 
    <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="lbtnSubject" EventName="Click" /> 
    </Triggers> 
+0

我得到一個錯誤這樣 ID爲「lbtnSubject」的控制不能在UpdatePanel的「UpdatePanel2」觸發器被發現。在System.Web.UI.UpdatePanelControlTrigger.FindTargetControl(布爾searchNamingContainers) – MAC 2010-05-17 06:38:18