User Control

Results 1 to 2 of 2

Thread: User Control

  1. #1
    Join Date
    Dec 1969

    Default User Control

    I just started on ASP.NET few weeks ago so pardon my dumb qustion.<BR><BR>I have created a user control which has a textbox and a search button. This will perform a search on a table based on the lastname of the users. Once the results are obtained i need to display them in a datagrid:<BR><BR>Below is the code<BR>===============USERCONTROL.aspx.vb======== ==========================<BR>&#039;&#039;&#039;&# 039;&#039;&#039;&#039;txt_LastName is the id of the txtbox that is apart of &#039;&#039;&#039;&#039;&#039;the user control<BR>Private Sub btn_Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Search.Click<BR> &#039;&#039;&#039;Call the stored procedure<BR> GetEmployeesByLastName()<BR>End Sub<BR>Private Sub GetEmployeesByLastName()<BR><BR><BR>Dim myReader As Data.SqlClient.SqlDataReader<BR>Dim cn As New System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationSettings.AppSettings("xxxxxxxx x"))<BR>Dim myCommand As New SqlClient.SqlCommand()<BR>Dim intNumberofRecords As Integer<BR>Try<BR> myCommand.Connection = cn<BR> myCommand.CommandType = CommandType.StoredProcedure<BR> myCommand.Parameters.Add("@vchLastName", Trim(UCase(txt_LastName.Text)) & "%")<BR> myCommand.CommandText = "spr_GetAllEmployees "<BR> cn.Open()<BR><BR> myReader = myCommand.ExecuteReader<BR> intNumberofRecords = myReader.RecordsAffected()<BR> &#039; Server.Transfer("someList.aspx")<BR>Catch ex As Exception<BR> Console.WriteLine(ex.Message)<BR>Throw<BR>Finally< BR><BR> cn.Close()<BR>End Try<BR><BR>======================================= =============<BR><BR>Problem:<BR><BR>Given the above code once the datareader has the records (the data is returning successfully) how do i get it to bind to a datagrid which is in another form "someList.aspx". Basically i want the datareader to be available across to a different page.<BR><BR><BR>Defenitely i am doing something wrong so any directions will help.<BR><BR><BR>Thanks You.<BR><BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: User Control

    I think u can pass it in a session variable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts