Radio button in HTML table cells using asp .net RRS feed

  • Question

  • 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.

    Private Sub Build()
        Dim htmlTable As New StringBuilder
        Dim data As New DataTable
        data = GetPageData()  ''Returns data from database
        If Not data Is Nothing And Also data.Rows.Count > 0 Then
            htmlTable.Append("<table style='text-align:center;' cellpadding='3' cellspacing='0' style = 'width:100%;' class='clsTable1' id = 'tblMain1' ")
            htmlTable.Append("   > ")
            BuildBody(htmlTable, data)
            tblBody.Rows(0).Cells(0).InnerHtml = htmlTable.ToString
            lblMessage.Text = "No data found"
            tblBody.Rows(0).Cells(0).InnerHtml = lblSpace.Text
    	End If
    End Sub
    Private Sub CreateHeaderRow(ByRef htmlTable As StringBuilder)
            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
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub CreateTableBody(ByRef htmlTable As StringBuilder, ByRef data As DataTable)
        Dim iRow As Integer
        Dim iCol As Integer
        Dim colData As String = String.Empty
            For iRow = 0 To data.Rows.Count - 1
                For iCol = 0 To data.Columns.Count - 1
                    colData = data.Rows(iRow).Item(iCol).ToString
                    If colData = String.Empty Then
                    End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub


    • Moved by Reed KimbleMVP Monday, May 21, 2018 11:44 AM in vb language
    Monday, May 21, 2018 2:32 AM


All replies

  • ASP.Net has their own Forums ASP.Net Forums which should be able to assist you.

    La vida loca

    Monday, May 21, 2018 2:41 AM
  • Note on a couple of things:

    1) Learn how to program on the client-side too using JavaScript at the browser and JavaScript plugins, like jQuery, Bootstrap.JS, Angular.JS, Knockout.js, Ajax and many other JavaScript plugins. It's more to it than just knowing how to do server-side programming with VB.NET and the codebehind file. 

    2) Know how to implement SoC with using layered or n-tier.

    3) Learn how to use SoD by using MVC or MVP with MVP being used for Web forms.

    4) Learn how to not use datasets and datatables, but rather, learn how to use straight-up ADO.NET, MS SQL Server command objects, parametrized inline T-SQL,  parametrized stored procedure, a datareader, custom object like a DTO as an individual object or collection of objects in a List(of T). Or figure out how to use that ADO.NET Entity Framework.

    Resources such as memory on Web server is finite and speed is at a premium too.

    The benefits are the same for VB or C# concerning the DTO.

    You can post to the ASP.NET forums that have already been mentioned.

    Monday, May 21, 2018 4:46 AM