D
Damon
Help! Need this fixed ASAP.
I have a GridView/DetailsView master/details form set up, with both
bound to separate ObjectDataSource objects. Both the GridView and the
DetailsView have a DataKeyNames parameter of "UserCompany,
BillableCompany". The DetailsView has control parameters for its
select method pointing to these two keys on the GridView. But the
select method function receives two copies of the UserCompany field!
The BillableCompany field never gets passed correctly.
What gives?
A simplified version of my ASP.NET code follows:
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="EditBillableCompanies.aspx.vb"
Inherits="EditBillableCompanies" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Billable Companies</title>
</head>
<body style="font-size: 12pt">
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:GridView ID="GridView1"
AutoGenerateColumns="False"
DataSourceID="MasterSource1"
DataKeyNames="UserCompany, BillableCompany"
runat="server">
<Columns>
<asp:CommandField ShowSelectButton="True"
/>
<asp:BoundField DataField="UserCompany"
HeaderText="User Company" />
<asp:BoundField DataField="BillableCompany"
HeaderText="Billable Company" />
</Columns>
</asp:GridView>
</td>
<td valign="top">
<aspetailsView ID="DetailsView1"
AutoGenerateRows="False"
DataSourceID="DetailsSource1"
DataKeyNames="UserCompany, BillableCompany"
EmptyDataText="No records."
runat="server">
<Fields>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ContactName"
HeaderText="Contact Name"
SortExpression="ContactName" />
<asp:BoundField DataField="ContactPhone"
HeaderText="Contact Phone"
SortExpression="ContactPhone" />
<asp:BoundField DataField="ContactEmail"
HeaderText="Contact Email"
SortExpression="ContactEmail" />
</Fields>
</aspetailsView>
</td>
</tr>
</table>
<asp:ObjectDataSource
ID="DetailsSource1"
TypeName="BillableCompaniesDetailView"
ConflictDetection="CompareAllValues"
SelectMethod="SelectBillableCompanies"
UpdateMethod="UpdateBillableCompanies"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
Name="UserCompany"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="GridView1"
Name="BillableCompany"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<UpdateParameters>
...
</UpdateParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource
ID="MasterSource1"
TypeName="BillableCompaniesMasterView"
SelectMethod="SelectBillableCompanies"
runat="server">
</asp:ObjectDataSource>
</div>
</form>
</body>
</html>
The BillableCompaniesDetailView class includes the following function:
Public Function SelectBillableCompanies(ByVal UserCompany As String, _
ByVal BillableCompany As String) As MySqlDataReader
BillableCompany is always the same value as UserCompany, and when this
function is called, they are both from the UserCompany field of my
MySql database.
Help!
Damon
I have a GridView/DetailsView master/details form set up, with both
bound to separate ObjectDataSource objects. Both the GridView and the
DetailsView have a DataKeyNames parameter of "UserCompany,
BillableCompany". The DetailsView has control parameters for its
select method pointing to these two keys on the GridView. But the
select method function receives two copies of the UserCompany field!
The BillableCompany field never gets passed correctly.
What gives?
A simplified version of my ASP.NET code follows:
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="EditBillableCompanies.aspx.vb"
Inherits="EditBillableCompanies" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Billable Companies</title>
</head>
<body style="font-size: 12pt">
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:GridView ID="GridView1"
AutoGenerateColumns="False"
DataSourceID="MasterSource1"
DataKeyNames="UserCompany, BillableCompany"
runat="server">
<Columns>
<asp:CommandField ShowSelectButton="True"
/>
<asp:BoundField DataField="UserCompany"
HeaderText="User Company" />
<asp:BoundField DataField="BillableCompany"
HeaderText="Billable Company" />
</Columns>
</asp:GridView>
</td>
<td valign="top">
<aspetailsView ID="DetailsView1"
AutoGenerateRows="False"
DataSourceID="DetailsSource1"
DataKeyNames="UserCompany, BillableCompany"
EmptyDataText="No records."
runat="server">
<Fields>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ContactName"
HeaderText="Contact Name"
SortExpression="ContactName" />
<asp:BoundField DataField="ContactPhone"
HeaderText="Contact Phone"
SortExpression="ContactPhone" />
<asp:BoundField DataField="ContactEmail"
HeaderText="Contact Email"
SortExpression="ContactEmail" />
</Fields>
</aspetailsView>
</td>
</tr>
</table>
<asp:ObjectDataSource
ID="DetailsSource1"
TypeName="BillableCompaniesDetailView"
ConflictDetection="CompareAllValues"
SelectMethod="SelectBillableCompanies"
UpdateMethod="UpdateBillableCompanies"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
Name="UserCompany"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="GridView1"
Name="BillableCompany"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<UpdateParameters>
...
</UpdateParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource
ID="MasterSource1"
TypeName="BillableCompaniesMasterView"
SelectMethod="SelectBillableCompanies"
runat="server">
</asp:ObjectDataSource>
</div>
</form>
</body>
</html>
The BillableCompaniesDetailView class includes the following function:
Public Function SelectBillableCompanies(ByVal UserCompany As String, _
ByVal BillableCompany As String) As MySqlDataReader
BillableCompany is always the same value as UserCompany, and when this
function is called, they are both from the UserCompany field of my
MySql database.
Help!
Damon