- Gridview disappearing on link click
- <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>
- 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);
- }
- }
- 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);
- }
- }
- }
- 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();
- }
- }