Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:10+00:00 2026-06-14T15:12:10+00:00

I have an HTML table to display a set of records from database after

  • 0

I have an HTML table to display a set of records from database after user entered a patient code or during Page Load when the patient code is passed through Querystring. Each data row has a Delete link button which is created dynamically.

I’d like to have the table refreshed after deletion. However, whenever the link button is clicked, it will postback and all the records will be wiped out unless I reload the data. If I reload the data again after deletion, there will be 2 times data fetching and the table rows will be doubled.

The first 2 rows of the tables are defined on the ASPX for easier styling purpose. If I cleared the table when fetching the data, the first rows will be wiped out as well. I have another 8 tables on different pages created in the same manner, hence I’d rather find other solution rather than defining and styling the rows from code behind.

Any help will be greatly appreciated.

The codes I use are as follow:

ASPX

<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="lblPatientCode" runat="server" Text="Patient Code : "></asp:Label>&nbsp; 
    <asp:TextBox ID="txtPatientCode" runat="server"></asp:TextBox>
    &nbsp;
    <asp:Button ID="btnFind" runat="server" name="Date" Text="Find" Width="90" CssClass="ButtonNormal" />
    <br /><br />

    <table id="tblDoctorInformation" class="PatientDetailsTable" runat="server">
        <tr><td colspan="2">DOCTOR INFORMATION</td></tr>
        <tr> 
            <td>Doctor In Charge</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    </div>
    </form>
</body>

Code Behind:

Protected PM As New PatientManagement.Common

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
        GetPatient()
    Else
        If txtPatientCode.Text <> "" Then
            GetPatient()
        End If
    End If
End Sub

Private Sub GetPatient()
    Dim sPatientCode As String = ""

    If IsPostBack Then
        sPatientCode = Trim(txtPatientCode.Text)
    Else
        sPatientCode = Trim(Page.Request.QueryString("PatientCode"))
    End If

    If sPatientCode <> "" Then
        Dim dr As SqlDataReader
        dr = PM.ExecuteReader("SELECT LOGID,DOCTORNAME FROM PMV_DOCTORINCHARGE WHERE PATIENTCODE='" & sPatientCode & "'")

        If dr.HasRows Then
            Do While dr.Read
                Dim tRow As New HtmlTableRow
                Dim tCellDoctorName As New HtmlTableCell
                Dim tCellModifyLink As New HtmlTableCell
                Dim lb As New LinkButton

                'Doctor Name
                tCellDoctorName.InnerHtml = PM.GetString_TableCell(dr("DoctorName"))
                tRow.Cells.Add(tCellDoctorName)

                'Delete links
                lb.Text = "Delete"
                lb.Attributes.Add("AutoPostBack", False)
                lb.CommandArgument = dr("LogID").ToString()
                AddHandler lb.Click, AddressOf DeleteRecord
                tCellModifyLink.Controls.Add(lb)
                tCellModifyLink.Align = "Center"
                tRow.Cells.Add(tCellModifyLink)

                tblDoctorInformation.Rows.Add(tRow)
            Loop
        End If
    End If
End Sub

Private Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click
    GetPatient()
End Sub

Protected Sub DeleteRecord(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim lbNew As New LinkButton
    Dim sResult As String = ""
    Dim bResult As Boolean
    lbNew = sender

    bResult = PM.DeleteMultiRecord(lbNew.CommandArgument, lbNew.CommandName, Session.Item("UserID"), sResult)
    If Not bResult Then
        MsgBox(sResult, MsgBoxStyle.OkOnly, "Deletion was not successful")
    Else
        GetPatient()
    End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:12:12+00:00Added an answer on June 14, 2026 at 3:12 pm

    I have searched around and it seems dynamic handler is best to be declared during PageInit. For my case, as the link button control needs to carry some values on the respective data row, it seems I can’t avoid calling GetPatient to create controls.

    To move on with the issue, I did a workaround by using Javascript. I created a hidLogID hidden field on ASPX page. I changed the link button to an <a> control and call a javascript function passing the dr("LogID"). The javascript function will assign the value to hidLogID and submit the page. PageLoad will call DeleteRecord()when hidLogID value is not blank. The value for hidLogID will be cleared on DeleteRecord().

    Thank you for all the help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML table in my jsp page. This conains text fields and
I have a html table with many cells and I would like to set
I have an AdvancedDataGrid being built dynamically from an html table. The html is
I have a page that uses jQuery tabs to tabify a set of HTML
I have a database table. I want the user to be able to modify
i have a page that displays large datasets into html tables. how can i
I have HTML table. I'm looping through table and iterate over each row whose
see fiddle i have html table and one textbox and one button.make cell selection
I have a html table like this: Invoice# Due Date Balance Select 12345 12/25/2011
I have an HTML table that contains some 500 rows. I have an input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.