FormView ObjectDataSource FormParameter can't find textbox if inside asp:table

H

hooterbite

I am using an object datasource to call a stored procedure to update an
SQL table.
THE STORED PROCEDURE WORKS FINE!
THE OBJECTDATASOURCE WORKS FINE!
When the textbox is inside a standard HTML tag <table>, it passes the
value of the textbox to the stored procedure, as expected.
When the textbox is inside an <asp:table> tag, the default value
assigned in the FormParameter tag is passed to the stored procedure, as
if it can't find the textbox.
See code below.
Thanks!

<UpdateParameters>
<asp:FormParameter formfield="subdetail_date" name="subdetail_date"
defaultvalue="1/1/01" />
</UpdateParameters>

<table><tr><td>
<asp:TextBox Text='<%# Bind("subdetail_date") %>' runat="server"
ID="subdetail_date" size="64" />
</td></tr></table>

<asp:table runat="server"><asp:tablerow><asp:tablecell>
<asp:TextBox Text='<%# Bind("subdetail_date") %>' runat="server"
ID="subdetail_date" size="64" />
</asp:tablecell></asp:tablerow></asp:table>
 
T

twostepted

I'm having the same type of problem. It seems as if when the control
referenced by the FormParameter is within another control, the
FormParameter can't correctly bind to the control. That really sucks!


Here are my params / form controls which aren't being picked up. The
reason that the tablerows are runat=Server is that they're being
selectively hidden in some postback code. I'm going to try and remove
the runat=server and do the hiding on the client to see if the update
problems dissappear. I'll write back if it works.

<tr id="trAccountInsert" runat="server">
<td class="clsLabel">Account:</td>
<td><asp:DropDownList ID="ddlAccountInsert" runat="server"
DataSourceID="DSAccounts"
SelectedValue = '<%# Bind("ACCOUNT_ID") %>'
DataValueField="ACCOUNT_ID"
DataTextField="ACCOUNT_NAME"
AppendDataBoundItems="true">
<asp:ListItem Value="" Text=" < none > " />
</asp:DropDownList></td></tr>
<tr id="trPartnerInsert" runat="server">
<td class="clsLabel">Partner:</td>
<td><asp:DropDownList ID="ddlPartnerInsert" runat="server"
DataSourceID="DSPartners"
SelectedValue = '<%# Bind("PARTNER_ID") %>'
DataValueField="PARTNER_ID"
DataTextField="PARTNER_NAME"
AppendDataBoundItems="true">
<asp:ListItem Value="" Text=" < none > " />
</asp:DropDownList></td></tr>
<tr>

<UpdateParameters>
...
<asp:FormParameter Name="ACCOUNT_ID" Type="Int32"
FormField="ddlAccountEdit" ConvertEmptyStringToNull="true" />
<asp:FormParameter Name="PARTNER_ID" Type="int32"
FormField="ddlPartnerEdit" ConvertEmptyStringToNull="true" />
</UpdateParameters>
 
T

twostepted

Sorry, when I said:
It seems as if when the control referenced by the FormParameter is
within another control, the FormParameter can't correctly bind to the
control.

I really meant:
It seems as if when the control referenced by the FormParameter is
within another control WITH RUNAT=SERVER, the FormParameter can't
correctly bind to the control.

I may be wrong and ASP.NET might just be renaming the control,
prepending the outer control with runat=server's name. If so, I would
have to change the name I used in the FormParameter, FieldName.

My solution was to keep the name the same and remove the runat=server.
It was better to show/hide the controls on the client anyway to avoid a
postback.

Yeah!
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top