Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

i have a web application with a page that divided into two sections. the first section is a search criteria, and the second section is the result view. the second view contains a table of the result and it is being created dynamically. so when a button click event in the first section fired the second section disappeared because the page is being posted back so it returns to its initial state.

i need these two sections to be separated in a way that when a button clicked in the first section the second section not affected. is this possible or not? if yes how?

thanks,

the vb code:

VB
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
        Dim myScript As String
        Try

            Dim doSearch As New Tracking
            Dim dtResult As New DataTable
            Dim txtvoter As New TextBox
            Dim tableCell As New TableCell
            Dim tblRow As New TableRow
            Dim lblfield As New Label
            Dim options As RadioButton

            Dim i As Integer
            Dim j As Integer


            doSearch.TrackingId = CInt(txtTrackingId.Text)
            dtResult = doSearch.Search
            If doSearch.Found Then
                lblCountNumber.Text = dtResult.Rows.Count.ToString
                lblfield = New Label
                lblfield.Text = "choose"
                lblfield.CssClass = "labels"
                tableCell = New TableCell
                tableCell.BorderStyle = BorderStyle.Solid
                tableCell.BorderColor = Drawing.Color.Black

                tableCell.Controls.Add(lblfield)
                tblRow.Cells.Add(tableCell)
                For i = 0 To dtResult.Rows.Count - 1
                    tableCell = New TableCell
                    tableCell.BorderStyle = BorderStyle.Solid
                    tableCell.BorderColor = Drawing.Color.Black
                    options = New RadioButton
                    options.GroupName = "options"
                    options.ID = "option" + i.ToString
                    options.Text = dtResult.Rows(i)("FormId")
                    options.CssClass = "option"

                    tableCell.Controls.Add(options)
                    tblRow.Cells.Add(tableCell)
                Next
                tblResult.Rows.Add(tblRow)


                For j = 0 To dtResult.Columns.Count - 1
                    tblRow = New TableRow
                    lblfield = New Label
                    lblfield.Text = dtResult.Columns.Item(j).ColumnName
                    lblfield.CssClass = "labels"

                    tableCell = New TableCell
                    tableCell.BorderStyle = BorderStyle.Solid
                    tableCell.BorderColor = Drawing.Color.Black
                    tableCell.Controls.Add(lblfield)
                    tblRow.Cells.Add(tableCell)
                    For i = 0 To dtResult.Rows.Count - 1
                        txtvoter = New TextBox
                        tableCell = New TableCell
                        tableCell.BorderStyle = BorderStyle.Solid
                        tableCell.BorderColor = Drawing.Color.Black
                        txtvoter.Text = dtResult.Rows(i)(j).ToString
                        txtvoter.CssClass = "labels"
                        tableCell.Controls.Add(txtvoter)
                        tblRow.Cells.Add(tableCell)

                    Next
                    tblResult.Rows.Add(tblRow)
                Next

                tblResult.Visible = True
                Session.Contents("tableView") = tblResult

            End If
        Catch ex As Exception
            myScript = "alert(" & ex.Message & ");"
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "myScript", myScript, True)
        End Try

    End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
        Dim myScript As String
        Try
            Dim i As Integer
            Dim obj As Object
            Dim formIdOption As RadioButton
            Dim formId As Integer
            Dim trackForm As Tracking

            tblResult = Session.Contents("tableView")

            For i = 1 To tblResult.Rows(0).Cells.Count - 1
                obj = tblResult.Rows(0).Cells(i).Controls(0)
                formIdOption = obj
                If formIdOption.Checked Then
                    formId = CInt(formIdOption.ID)
                    Exit For
                End If
            Next

            trackForm = New Tracking
            trackForm.formId = formId
            trackForm.update()
           
        Catch ex As Exception
          
        End Try

    End Sub


the asp code:

ASP.NET
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Search.aspx.vb" Inherits="Analysis.Search" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="ar" dir="rtl">
<head id="Head1" runat="server">
    
</head>
<body>
    <form id="form1" runat="server">
    <div id="searchView">
    <table id="tblSearch" style="width:100%;">
                        <tr>
                            
                            <td>
                                <asp:Label ID="lblSearch" cssclass="labels" runat="server" Text="search"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtTrackingId" cssclass="labels" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            
                            <td>
                                <asp:Label ID="lblCount" cssclass="labels" runat="server" Text="count"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="lblCountNumber" CssClass="labels" runat="server" Text=""></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            
                            <td>
                                <asp:Button ID="btnSearch" cssclass="labels" runat="server" Text="search" />
                            </td>
                            <td>
                                <asp:Button ID="btnSave" cssclass="labels" runat="server" Text="save" />
                            </td>
                        </tr>
                    </table>
 
    </div>
   
    <div class="divtable">
    <asp:table runat="server" ID="tblResult"  Visible="False" >

    </asp:table>
    </div>
    </form>
</body>
</html>
Posted
Updated 1-Feb-13 0:49am
v2
Comments
Adam R Harris 31-Jan-13 16:59pm    
Post a sample of your code, we cannot see your monitor or read your mind. Your issue could relate to several things so please use the Improve Question link to add more detail and some code samples (the specific code that generates the dynamic results grid, the code that calls the method that generates the results and the markup for the page)

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900