Sunday, February 19, 2012

Gridview question

Sqldatasources are used for a dropdownlist and a gridview. How can the dropdownlist selection refresh the gridview? This is done programmatically in ASP.NET 1.1 code behind. Can it be done in ASP.NET 2.0 without code behind? Thanks.

Hi,

the SqlDataSource controls hasfilterparameters that you can set through the wizard, or in markup, and then you can use for example the controlparameter:

<asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/>

Be sure totake a look at this example.

Grz, Kris.

|||

Thanks. But how can the following be implemented in the FilterParmeters?

Sub LoadGrid()
Dim sqlText As String
If IsPostBack And cboState.SelectedValue <> "0" Then
sqlText = "SELECT * FROM Customers WHERE State='" & cboState.SelectedValue & "'"
Else
sqlText = "SELECT * FROM Customers"
End If
gridCust.DataSource = GetDataView(sqlText, cnn)
gridCustDataBind()
End Sub

No comments:

Post a Comment