Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Radio button in HTML table cells using asp .net VB

$
0
0

I have a application which fetches data from database and displays the data on a ASP page using VB as follows. The function GetPageData() returns data from database in a table form.

I now need to add two more columns (Details & History) in this table, which are radio buttons for each row and when user clicks the radio button, a new page should open displaying details or history page depending upon radio button clicked.

Below is the existing code. Could anyone help me understand how I can achieve this. I am new to .NET & frontend programming.

PrivateSub Build()Dim htmlTable AsNew StringBuilderDim data AsNew DataTable
    data = GetPageData()''Returns data from databaseIfNot data IsNothingAnd Also data.Rows.Count >0Then
        htmlTable.Append("<table style='text-align:center;' cellpadding='3' cellspacing='0' style = 'width:100%;' class='clsTable1' id = 'tblMain1' ")
        htmlTable.Append("   > ")
        BuildHeader(htmlTable)
        BuildBody(htmlTable, data)
        htmlTable.Append("</tr>")
        htmlTable.Append("</table><br><br>")
        tblBody.Rows(0).Cells(0).InnerHtml = htmlTable.ToStringElse
        lblMessage.Text ="No data found"
        tblBody.Rows(0).Cells(0).InnerHtml = lblSpace.TextEndIfEndSubPrivateSub CreateHeaderRow(ByRef htmlTable As StringBuilder)Try
        htmlTable.Append("<tr bgcolor='#D3D3D3' style='font-weight:bold;' >")
        htmlTable.Append(" <td align='center'> Customer ID</td>")
        htmlTable.Append(" <td align='center'> Customer Name</td>")
        htmlTable.Append(" <td align='center'> Customer Address</td>")
        htmlTable.Append(" <td align='center'> Details</td>")'New Column Header for radio button
        htmlTable.Append(" <td align='center'> History</td>")'New Column Header for radio button
        htmlTable.Append("</tr>")Catch ex As ExceptionThrow exEndTryEndSubPublicSub CreateTableBody(ByRef htmlTable As StringBuilder,ByRef data As DataTable)Dim iRow AsIntegerDim iCol AsIntegerDim colData AsString=String.EmptyTryFor iRow =0To data.Rows.Count -1For iCol =0To data.Columns.Count -1
                colData = data.Rows(iRow).Item(iCol).ToStringIf colData =String.Empty Then
                    htmlTable.Append("&nbsp;")Else
                    htmlTable.Append(colData)EndIf
                htmlTable.Append("</td>")Next

        htmlTable.Append("</tr>")NextCatch ex As ExceptionThrow exEndTryEndSub

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>