Button click & filtering a GridView


J

Jokke

Hi,

* Click event doesn't fire?

On clicking a button, my gridview should be filtered with the value typed in
a textbox.

It works, but only the second time you click the button. First click ->
nothing.

To be on the safe side, I already removed the button and put another one
there (with other name), but the behavior still stands.

I am a first timer in ASP.NET, so I must be missing something. I tried
debugging, and the click event simply doesn't fire the first time you click
the button... Please advise!

the code is:

Protected Sub btnFilterSupplName_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles btnFilterSupplName.Click
SqlDataSource2.FilterExpression = "[SupplierName] LIKE '%" &
Me.txtSearchSupplName.Text & "%'"
Me.GridView1.DataBind()
End Sub

* Selecting the first GridView record

The GridView has a Select column, and a Details View control is bound to it
If the textbox/button filtering yields results in the GridView, I would like
the DetailsView to display the first record in the GridView, as if the user
had clicked on the Select of the first GridView record.
How can I do this?

thank you for your help!
 
Ad

Advertisements

J

James VanDyne

Can you post the code where you are telling the button about this event
handler? For example, are you setting Click="btnFilterSupplName_Click" in
the HTML markup or are you maybe doing this in a Page Load event, etc...
 
Ad

Advertisements

J

Jokke

It is the button click event alright.

btnFilterSCode_Click

Actually happens with 2 buttons, on their respective click events...

Thx for helping.


James VanDyne said:
Can you post the code where you are telling the button about this event
handler? For example, are you setting Click="btnFilterSupplName_Click" in
the HTML markup or are you maybe doing this in a Page Load event, etc...


Jokke said:
Hi,

* Click event doesn't fire?

On clicking a button, my gridview should be filtered with the value typed
in a textbox.

It works, but only the second time you click the button. First click ->
nothing.

To be on the safe side, I already removed the button and put another one
there (with other name), but the behavior still stands.

I am a first timer in ASP.NET, so I must be missing something. I tried
debugging, and the click event simply doesn't fire the first time you
click the button... Please advise!

the code is:

Protected Sub btnFilterSupplName_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles btnFilterSupplName.Click
SqlDataSource2.FilterExpression = "[SupplierName] LIKE '%" &
Me.txtSearchSupplName.Text & "%'"
Me.GridView1.DataBind()
End Sub

* Selecting the first GridView record

The GridView has a Select column, and a Details View control is bound to
it
If the textbox/button filtering yields results in the GridView, I would
like the DetailsView to display the first record in the GridView, as if
the user had clicked on the Select of the first GridView record.
How can I do this?

thank you for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top