Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:21:38+00:00 2026-05-14T23:21:38+00:00

I have a problem with my FromView. I would like to show some data

  • 0

I have a problem with my FromView.
I would like to show some data from a Database Table in my FormView. But some data is from the tupe Int32, while this data should be in a TextBox, a string.

How do you convert these Int32’s.

FormView and my ObjectDataSource

<asp:FormView ID="fvDetailOrder" runat="server">
 <ItemTemplate>
        Aantal:<br />
        <asp:Label CssClass="txtBox" ID="Label15" runat="server" Text='<%# Eval("COUNT") %>' /><br />
        Prijs:<br />
        <asp:Label CssClass="txtBox" ID="Label16" runat="server" Text='<%# Eval("PRICE") %>' /><br />
        Korting:<br />
        <asp:Label CssClass="txtBox" ID="Label17" runat="server" Text='' /><br />
        Totaal:<br />
        <asp:Label CssClass="txtBox" ID="Label18" runat="server" Text='<%# Eval("AMOUNT") %>' /><br />
        Betaald:<br />
        <asp:Label CssClass="txtBox" ID="Label19" runat="server" Text='<%# Eval("PAID") %>' /><br />
        Datum betaling:<br />
        <asp:Label CssClass="txtBox" ID="Label20" runat="server" Text='<%# Eval("PDATE") %>' /><br />
    </ItemTemplate>
</asp:FormView>

<asp:ObjectDataSource ID="objdsOrderID" runat="server" 
    OnSelecting="objdsOrderID_Selecting" SelectMethod="getOrdersByID" 
    TypeName="DAL.OrdersDAL">
    <SelectParameters>
        <asp:Parameter Name="id" Type="Int32" />
    </SelectParameters>
</asp:ObjectDataSource>

My Code behind

protected void gvOrdersAdmin_SelectedIndexChanged(object sender, EventArgs e)
{
    fvDetailOrder.DataSource = objdsOrderID;
    fvDetailOrder.DataBind(); //  <-- HERE I GET THE ERROR
}

protected void objdsOrderID_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
    e.InputParameters["id"] = gvOrdersAdmin.DataKeys[gvOrdersAdmin.SelectedRow.RowIndex].Values[0];
}

My Data Acces Layer

public static DataTable getOrdersByID(string id)
{
    string sql = "SELECT 'AUTHOR' = tblAuthors.FIRSTNAME + ' ' + tblAuthors.LASTNAME, tblBooks.*, tblGenres.*, tblLanguages.*, tblOrders.* FROM tblAuthors INNER JOIN tblBooks ON tblAuthors.AUTHOR_ID = tblBooks.AUTHOR_ID INNER JOIN tblGenres ON tblBooks.GENRE_ID = tblGenres.GENRE_ID INNER JOIN tblLanguages ON tblBooks.LANG_ID = tblLanguages.LANG_ID INNER JOIN tblOrders ON tblBooks.BOOK_ID = tblOrders.BOOK_ID"
        + " WHERE tblOrders.ID = @id;";

    SqlDataAdapter da = new SqlDataAdapter(sql, GetConnectionString());

    da.SelectCommand.Parameters["id"].Value = id;

    DataSet ds = new DataSet();
    da.Fill(ds, "Orders");

    return ds.Tables["Orders"];
}

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:21:39+00:00Added an answer on May 14, 2026 at 11:21 pm

    You set parameter “id” ‘s value with type of string. But tblOrders.ID is type of int.

    Try this:

    da.SelectCommand.Parameters["id"].Value = Int32.Parse(id);
    

    or even this (will work little bit more fast and safe than previous code):

    int i;
    if (Int32.TryParse(id, out i))
    {
       da.SelectCommand.Parameters["id"].Value = i;
    }
    else
    {
       throw new ArgumentException("id");
    }
    

    Also it’s better do next:

    var table = CreateDataTable();
    new SqlDataAdapter(command).Fill(table);
    return table;
    

    instead of using DataSet

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem SIMILAR to preventing form data reposting, but not quite the same
In my MVC application I have a problem with passing data from view to
i have problem to pass data from view to controller , i have view
I am new to MVC. i have problem to pass data from view to
the problem is that I do have an ASP.NET TextBox in a FormView with
I have problem with show or hide form in Window Form Application. I start
I have problem with UIWebView delay when the load image from url. In my
I have problem while loading data into html select when users press or click
I have a formview on my aspx page containing various controls arranged using table.
Basically I have a set of checkboxes that are dynamically created from view data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.