2012-01-17 92 views
0

當我們的生產服務器上點擊一個鏈接時,我的GridView消失,我有一個真實的不穩定的情況。Gridview在鏈接點擊消失

它的工作原理是這樣的:

  • 用戶執行搜索時,GridView控件獲取生成
  • 在頁面生成,鏈接獲取生成的鏈接
  • 用戶點擊,並在GridView消失。

在過去,我遇到過只有鏈接會消失的問題,因爲鏈接是在頁面生命週期的後期生成的。但這一次它似乎有所不同。

什麼讓這更奇怪的是,這隻發生在我們的生產/活服務器上的IIS。如果我在IIS下使用完全相同的編譯代碼,完全相同的數據庫連接字符串等創建新的網站,則GridView將起作用。

這裏是包含在GridView的部分:

<div class="PGE_SearchResult">  
<asp:Panel ID="pnlWrapper" runat="server" CssClass="addSearchPanelStyle">   
    <asp:GridView ID="gvExistingPatientsSearch" runat="server" AutoGenerateColumns="false" DataKeyNames="PatientId" CssClass="addSearchGridViewStyle" 
     AlternatingRowStyle-CssClass="STD_GridView_AlternateRow" RowStyle-CssClass="STD_GridView_Row" 
     HeaderStyle-CssClass="gvFixedHeader" FooterStyle-CssClass="STD_GridView_Footer" 
     OnRowDataBound="gvExistingPatientsSearch_RowDataBound"> 
     <Columns> 
      <asp:TemplateField HeaderText="Patient ID" ItemStyle-CssClass="PGS_PSR_PatientID"> 
       <ItemTemplate> 
        <asp:LinkButton ID="lnkPatientSearch" runat="server" Text='<%# Bind("PatientId")%>' OnClick="OnPatientIDClick" CommandArgument='<%# Eval("PatientId")+ ";" + Eval("PatientStatus")+ ";" + Eval("DOB") + ";" + Eval("DiseaseStates") + ";" + Eval("DiseaseStateIds")%>'></asp:LinkButton> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:BoundField DataField="PatientName" HeaderText="Patient Name" ItemStyle-CssClass="PGS_PSR_Site"/> 
      <asp:BoundField DataField="DOB" HeaderText="Date of Birth" HtmlEncode="False" ItemStyle-CssClass="PGS_PSR_DOB"/> 
      <asp:TemplateField HeaderText="Site(s)" SortExpression="Site" ItemStyle-CssClass="PGS_PSR_Site"> 
       <ItemTemplate> 
        <asp:Label ID="lblSiteSearch" runat="server" Text='<%# Bind("Site")%>'></asp:Label>       
       </ItemTemplate> 
      </asp:TemplateField>    
      <asp:BoundField DataField="SiteMRN" HeaderText="Site MRN" HtmlEncode="False" ItemStyle-CssClass="PGS_PSR_DOB"/> 
      <asp:TemplateField HeaderText="Disease State(s)" ItemStyle-CssClass="PGS_PSR_Site"> 
       <ItemTemplate> 
        <asp:Panel ID="diseaseStatePanel" runat="server"> 
        </asp:Panel> 
      </ItemTemplate> 
      </asp:TemplateField>       
     </Columns> 
    </asp:GridView> 
</div> 

其爲GridView生成的行的代碼是這樣的:

protected void gvExistingPatientsSearch_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    DataRowView patientData = (DataRowView)e.Row.DataItem; 
    string diseaseStates = patientData["DiseaseStates"] as string; 
    string diseaseStateIds = patientData["DiseaseStateIDs"] as string; 
    int PatientID = (int)patientData["PatientId"]; 
    int patientStatus = (int)patientData["PatientStatus"]; 
    DateTime DOB = DateTime.Parse(patientData["DOB"] as string); 
    if (e.Row.RowIndex != -1) 
    { 
     e.Row.Cells[2].Enabled = true; 

     LinkButton lnkPatientSearch = (LinkButton)e.Row.FindControl("lnkPatientSearch"); 
     lnkPatientSearch.Enabled = false; 

     Panel diseaseStatePanel = (Panel)e.Row.FindControl("diseaseStatePanel"); 
     BuildDiseaseStateLinks(diseaseStatePanel, diseaseStates, diseaseStateIds, PatientID, patientStatus, DOB, true); 
    } 
} 

下面是該方法BuildDiseaseStatelinks()

private void BuildDiseaseStateLinks(Panel diseaseStatePanel, string diseaseStates, string diseaseStateIDs, int PatientID, int patientStatus, DateTime DOB, bool isAllowed) 
{ 
    string[] diseaseStateIdsSplit = diseaseStateIDs.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); 

    string[] diseaseStateSplit = diseaseStates.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); 

    for (int i = 0; i < diseaseStateSplit.Length; i++) 
    { 
     string diseaseState = diseaseStateSplit[i]; 
     string diseaseStateID = diseaseStateIdsSplit[i]; 

     LinkButton diseaseStateLink = new LinkButton(); 
     diseaseStateLink.Attributes.Add("style", "float:left"); 
     diseaseStateLink.Text = diseaseState; 
     diseaseStateLink.CommandArgument = 
      PatientID + "|" + patientStatus + "|" + DOB.ToShortDateString() + "|" + diseaseState + "|" + diseaseStateID; 

     if (isAllowed) 
     { 
      diseaseStateLink.CommandArgument += "|Allowed"; 
     } 
     else 
     { 
      diseaseStateLink.CommandArgument += "|NotAllowed"; 
     } 

     diseaseStateLink.CommandName = "OnDiseaseStateLinkClick"; 
     diseaseStateLink.Command += new CommandEventHandler(OnDiseaseStateLinkClick); 

     diseaseStatePanel.Controls.Add(diseaseStateLink); 

     if (i < diseaseStateSplit.Length - 1) 
     { 
      Label splitLabel = CreatePipeLabel(); 
      diseaseStatePanel.Controls.Add(splitLabel); 
     } 
    } 
} 

gvExistingPatientsSearch被限制在2個地方,當s earch按鈕被點擊,並在Page_Load上,但只有當用戶被重定向到當前頁面並且搜索爲QueryString

一旦鏈接被點擊,幾Session變量獲取設置(在CommandArguments組發現BuildDiseaseStateLinks的那些和用戶被重定向到另一個網頁。

我該怎麼辦可能會丟失?碼是數據庫是相同的,數據庫是相同的,IIS設置是相同的(除了應用程序池,一個是使用經典(Prod/Live)和其他集成;我切換Prod/Live到Integrated,並沒有做任何事情

建議,意見,任何事情!

Thanks in提前。

[編輯]:根據要求添加了一些代碼。原本並沒有這樣做,因爲我認爲代碼可能不是問題。它適用於一個版本,而不是其他版本。

+0

呵呵。我認爲你應該顯示你的代碼。必須有一些特定的參數傳遞進去。 – Doomsknight 2012-01-17 16:33:32

+0

你的頁面是否包含updatepanel更好地向我們展示標記以及鏈接按鈕的作用 – Devjosh 2012-01-17 16:35:06

+1

也許在鏈接回發之後生成GridView時會拋出異常?你用try/catch檢查錯誤嗎? – Brissles 2012-01-17 16:36:23

回答

1

找出問題所在。這是一個安全的網站和一個不是的區別,真正的區別是* http *** s **和http,是的s是什麼導致了這個問題。原因是我重新綁定了OnInit上的DataSource,這樣當鏈接被點擊時,事件就會被創建並觸發。這是一個解決方案suggestedquestion我前一段時間問過。

我所做的一切是這樣的:

protected override void OnInit(EventArgs e) 
{ 
    base.OnInit(e); 

    // if being redirected from another page, remove the search attributes 
    // so it doesn't load the Search Grid view 
    if (Page.Request.UrlReferrer != Page.Request.Url) 
    { 
     Session[UNMGeneralConstants.SearchAttributes] = null; 
    } 

    UserManagementBO userManagementBO = new UserManagementBO(); 
    dsUserInSites = userManagementBO.GetSitesNameForUser(new Guid(Session[SessionVariables.Ses_UserId].ToString())); 

    DataSet dsSearchResults2 = Session[UNMGeneralConstants.SearchAttributes] as DataSet; 
    if (dsSearchResults2 != null && dsSearchResults2.Tables.Count != 0) 
    { 
     gvExistingPatientsSearch.DataSource = dsSearchResults2; 
     gvExistingPatientsSearch.DataBind(); 
    } 
    else 
    { 
     gvExistingPatientsSearch.DataSource = null; 
     gvExistingPatientsSearch.DataBind(); 
    } 
} 

這是if (Page.Request.UrlReferrer != Page.Request.Url)聲明,因爲UrlReferrer有https這是導致問題和URL沒有。我已將if聲明改爲if(Page.Request.UrlReferrer.LocalPath != Page.Request.Url.LocalPath)。它在測試之後似乎起作用。

希望這是最終的解決方案,我不會再有問題了。建議和意見非常感謝。