Getting Value from FormView

Last post 03-31-2007 9:46 AM by rswetnam. 2 replies.

Sort Posts:

  • Getting Value from FormView

    03-27-2007, 7:51 PM
    • Member
      35 point Member
    • rswetnam
    • Member since 12-30-2006, 3:55 PM
    • Posts 143

    Hi:

    I have created a form called FormView1 using the FormView control and bound it to an ObjectDataSource.  FormView 1 contains an item? called Media_ID which is an int drawn from the ObjectDataSource. 

    I would like to be able to get the value of Media_ID.  I have tried to use the help - but have been quite overwhelmed.  I vaguely remember a lifetime ago programming in Vb and Access that I could look up a term and it would show me its property and methods as well give sample bits of code - e.g. getting the value from a ListBox.  Can't seem to do that - maybe there's something quite simple I am missing?

    So, I have 2 questions that I would appreciate some help on.

    1. How do I get the value of Media_ID from my FormView1?
    2. What is the easiest way form me to get this information from the help menu?

    Regards,

    Roger Swetnam 

     

     

     


     

  • Re: Getting Value from FormView

    03-27-2007, 10:43 PM
    Answer

    Dear, friend:

    You can set the DataKeyNames of the FormView to you PK in the DB.

     <asp:FormView ID="FormView1" runat="server" OnItemUpdating="FormView1_ItemUpdating"
                    AllowPaging="True" DataKeyNames="ProductID" DataSourceID="SqlDataSource3" OnDataBinding="FormView1_DataBinding">

    And retrive it in code behind as following:

    this.FormView1.DataKey["name"].ToString();

    I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
  • Re: Getting Value from FormView

    03-31-2007, 9:46 AM
    • Member
      35 point Member
    • rswetnam
    • Member since 12-30-2006, 3:55 PM
    • Posts 143

    Thanks Rex - this was exactly what I was looking for.

     Roger Swetnam
     

Page 1 of 1 (3 items)