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

Discussion in 'ASP .Net' started by hooterbite@yahoo.com, Apr 26, 2006.

  1. Guest

    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>
     
    , Apr 26, 2006
    #1
    1. Advertising

  2. twostepted Guest

    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>
     
    twostepted, Apr 30, 2006
    #2
    1. Advertising

  3. twostepted Guest

    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!
     
    twostepted, Apr 30, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wikkiwikkiwaa
    Replies:
    2
    Views:
    12,694
    wikkiwikkiwaa
    Aug 9, 2006
  2. Jai
    Replies:
    0
    Views:
    2,306
  3. Jai
    Replies:
    0
    Views:
    776
  4. Replies:
    0
    Views:
    532
  5. HockeyFan
    Replies:
    1
    Views:
    1,033
    Masudur
    Jul 4, 2007
Loading...

Share This Page