G
Guest
I have two tables I'm editing in a Gridview. The VANS table contains a key to
the other LESSOR table. I would like to use a dropdown list to select the
LessorId value while displaying the Lessor table's "Company" field as text.
When I commit the edit I get error:Must declare the scalar variable
"@LessorId".
Also as a bonus question
I don't know how to set the selectedindex value
in the dropdown list based on the LessorId value in the Vans table.
Any ideas would be appreciated!
Thanks.
Here's my templatefield:
<asp:TemplateField HeaderText="Company" >
<ItemTemplate>
<asp:literal ID="Literal1" runat="server" Text='<%# Eval("Company") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp
ropDownList ID="ddlCompany" runat="server"
DataSourceID="sdsLessors" DataTextField="Company" DataValueField="LessorId">
</asp
ropDownList>
</EditItemTemplate>
</asp:TemplateField>
Gridview's SqlDataSource:
<asp:SqlDataSource ID="sdsVans" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT v.VanNo, v.LessorId, v.Status, v.Active,
l.Company, l.Account FROM dbo.Van v join dbo.Lessors l ON
v.LessorId=l.LessorId order by VanNo"
UpdateCommand="Update dbo.Vans set VanNo=@VanNo, LessorId=@LessorId,
Status=@Status,Active=@Active where LessorId=@LessorId" >
</asp:SqlDataSource>
DropDownList's SqlDataSource:
<asp:SqlDataSource ID="sdsLessors" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT LessorId, Company, Account FROM dbo.Lessors
order by Company">
</asp:SqlDataSource>
the other LESSOR table. I would like to use a dropdown list to select the
LessorId value while displaying the Lessor table's "Company" field as text.
When I commit the edit I get error:Must declare the scalar variable
"@LessorId".
Also as a bonus question
in the dropdown list based on the LessorId value in the Vans table.
Any ideas would be appreciated!
Thanks.
Here's my templatefield:
<asp:TemplateField HeaderText="Company" >
<ItemTemplate>
<asp:literal ID="Literal1" runat="server" Text='<%# Eval("Company") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp
DataSourceID="sdsLessors" DataTextField="Company" DataValueField="LessorId">
</asp
</EditItemTemplate>
</asp:TemplateField>
Gridview's SqlDataSource:
<asp:SqlDataSource ID="sdsVans" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT v.VanNo, v.LessorId, v.Status, v.Active,
l.Company, l.Account FROM dbo.Van v join dbo.Lessors l ON
v.LessorId=l.LessorId order by VanNo"
UpdateCommand="Update dbo.Vans set VanNo=@VanNo, LessorId=@LessorId,
Status=@Status,Active=@Active where LessorId=@LessorId" >
</asp:SqlDataSource>
DropDownList's SqlDataSource:
<asp:SqlDataSource ID="sdsLessors" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT LessorId, Company, Account FROM dbo.Lessors
order by Company">
</asp:SqlDataSource>