Click here to Skip to main content
15,906,645 members

Comments by Cute Girly Geek (Top 6 by date)

Cute Girly Geek 1-Sep-16 22:04pm View    
Thank you R.D. It worked.... whew!!! Thanks again! :*
Cute Girly Geek 14-Aug-16 22:44pm View    
Thank you so much 0x01AA! Your response is a gem. :)
Cute Girly Geek 11-Aug-16 23:14pm View    
Thank you Mr. Richard.. Sorry for the late reply.. its the design of my form that is... I think is at fault.. I tried everything to be done in one form. (nilesh sawardekar was right at that).. So I just created a new form for my search and it was working. Though I would really love to get an example of viewstate. Thanks again. :)
Cute Girly Geek 11-Aug-16 23:14pm View    
Thank you Mr. Richard.. Sorry for the late reply.. its the design of my form that is... I think is at fault.. I tried everything to be done in one form. (nilesh sawardekar was right at that).. So I just created a new form for my search and it was working. Though I would really love to get an example of viewstate. Thanks again. :)
Cute Girly Geek 1-Aug-16 23:35pm View    
Deleted
Hello Again,
I kinda cleaned my code a bit. I also used a viewstate.. but I still get the error.
<pre lang="vb">
Protected Sub lnkSearch_Click(sender As Object, e As EventArgs) Handles lnkSearch.Click
Dim strSearch As String

strSearch = "SELECT Fid,RealName,Department FROM tblUsers" &
" WHERE RealName LIKE '%" & txtName.Text & "%'"

Dim constring As String = "Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=dbTOD_Sql;Integrated Security=True"
Using con As New SqlConnection(constring)
Using cmd As New SqlCommand(strSearch, con)
cmd.CommandType = CommandType.Text
Using sda As New SqlDataAdapter(cmd)
Using dt As New DataTable()
sda.Fill(dt)

'Set AutoGenerateColumns False
GridView1.AutoGenerateColumns = False

'First time knowing ViewState. HOpe this works
ViewState("vsTable") = dt
'Reading the viewstate values.
Dim dt2 As DataTable = DirectCast(ViewState("vsTable"), DataTable)
GridView1.DataSource = dt2
GridView1.DataBind()
End Using
End Using
End Using
End Using
End Sub
</pre>