Hello,
Have a question that I am sure has a simple answer. That's why I'm here!
Basically I have a gridview and a few buttons within module.
I am currently able to view data within gridview from sql database.
Here is the code I am using for viewing existing data.
Sample Code:
Private Sub ShowData(ByVal SearchString As String)
Dim mySqlString As New StringBuilder()
mySqlString.Append("SELECT FirstName, LastName, Address, City, State ")
mySqlString.Append("FROM {databaseOwner}{objectQualifier} UserInformation ")
mySqlString.Append("WHERE LastName like '%' + @SearchString + '%' ")
mySqlString.Append("ORDER BY FirstName")
Dim myParam As SqlParameter = New SqlParameter("@SearchString", SqlDbType.VarChar, 150)
myParam.Value = SearchString
Me.GridView2.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)Me.GridView2.DataBind()
End
Sub
Presently the data is being sorted by FirstName.
I would like to have a dropdown, checkboxes or buttons that give a few options of how to sort.
So whether dropdown, checkbox or buttons, options would be sort by Address, City, State, etc.
I am familiar with vb coding and have tried rigging events for each individual button, but it seems that more than one
DataSource and Params make module error out.
I actually could see this working best as an if / then statement within same event, but am not sure how the
code would break up for the different options. The only other thing I could think of, would be to rig each option, whether
dropdown, checkbox or buttons to operate accordingly when clicked.
But cannot find code for button1.clicked = true....or something to that effect.
(as in: to be placed within code above, not referring to Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
I am actually awaiting a response on this concern from within another post.
Here's what I need to know:
1. Can I run multiple events using samplecode, with different parameters for each?
Meaning: In each Protected Sub btn_Click (of each button option), using the samplecode, but with different sort orders.
If so, what tags must be changed in samplecode? (ex: Dim mySqlString changed to Dim mySqlString2)
2. Is it better to create multiple events like asked in Question #1, or to create an if / then statement that does this?
3. Is there code within asp.net for the value of a button, checkbox, dropdown being clicked outside of it's own sub?
4. What is your suggested code for this fix?
-Machina12