Hi!
I have a form containing a GridView and a FormView. When a row is selected in the GridView, I would like the details of that row to appear in the FormView. The key to retrieve the FormView data is based on two fields in the database. However, I cannot get this to work.
Here is the GridView Data Source:
<data:ImportMatchDetailsDataSource ID="dsImportMatchDetails"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
EnableTransaction="False"
runat="server">
<Parameters>
<data:SqlParameter Name="WhereClause" UseParameterizedFilters="false">
<Filters>
<data:ImportMatchDetailsExpressionBuilder Column="ImportDatabaseID" QueryStringField="ImportDatabaseID" BuilderExpression="AppendEquals" />
<data:ImportMatchDetailsExpressionBuilder Column="ClientNo" QueryStringField="ClientNo" BuilderExpression="AppendEquals" />
<data:ImportMatchDetailsExpressionBuilder Column="BonMatch" BuilderExpression="AppendIsNull" />
</Filters>
</data:SqlParameter>
</Parameters>
</data:ImportMatchDetailsDataSource>
And here is the FormView DataSource:
<data:ImportMatchDetailsDataSource ID="dsSelectedImportMatchDetails"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
EnableTransaction="False"
runat="server">
<Parameters>
<data:SqlParameter Name="WhereClause" UseParameterizedFilters="false" ConvertEmptyStringToNull="true">
<Filters>
<data:ImportMatchDetailsFilter Column="ImportDatabaseID" QueryStringField="ImportDatabaseID" ComparisionType="Equals" DefaultValue="0" />
<data:ImportMatchDetailsFilter Column="ClientID" ControlID="gvwMatches" PropertyName="SelectedDataKey[0]" ComparisionType="Equals" DefaultValue="0" />
<data:ImportMatchDetailsFilter Column="ExtID" ControlID="gvwMatches" PropertyName="SelectedDataKey[1]" ComparisionType="Equals" DefaultValue="0" />
</Filters>
</data:SqlParameter>
</Parameters>
</data:ImportMatchDetailsDataSource>
On both the GridView and the FormView, I have DataKeyNames="ClientID,ExtID"
Now, when I load the form, nothing is selected in the GridView, so I would expect the FormView to show the EmptyDataTemplate, but it is not the case. I checked what is the query being sent to SQL Server, and here are the WhereClause and other parameters passed to the FormView DataSource query:
'@WhereClause nvarchar(25),@OrderBy nvarchar(4000),@PageIndex int,@PageSize int',@WhereClause=N' (ImportDatabaseID =
''1'')',@OrderBy=N'',@PageIndex=0,@PageSize=2147483647
As one can see, the only filter parameter passed is ImportDatabaseID. What happened to the ClienID and ExtID filters?
Moreover, when I select a row in the GridView, no query is sent to SQL Server. Is this normal?
I added a OnSelectedIndexChanged method to the GridView in which I force a DataBind() on the GridView. However, the only filter parameter passed to the query is still ImportDatabaseID.
Another thing I tried was to add a OneToOneViewRelationship between the GridView and the FormView, but this did not help either.
Cheers!
JF