error on datagrid- unknown webcontrol error

Posted on 2007-08-02
Last Modified: 2009-07-29
I am getting the following error:
No mapping exists from object type System.Web.UI.WebControls.TemplateField to a known managed provider native type.

I have 2 datagrids.  one datagrid is a result of a search and the the column I am trying to obtain from datagrid one is [4].  in my select statement for the 2nd datagrid, a match is found in the designated table.  however, when i select match, I get the above error.  the error is supposedly on the datasource, but upon closer examination, I think it's my: commshow.Parameters.AddWithValue("@shownum", appReqsGrid.Columns[4]);
how can I obtain the value from column 4 in the first datagrid (data is passed through a link - find match) to become part of my query in my second datagrid?

here's the code from the second datagrid:

=====some of the code====

string bon = ConfigurationManager.ConnectionStrings["RevisedTapeLibrary"].ConnectionString;
                   SqlConnection connsho = new SqlConnection(bon);
                   SqlCommand commshow = new SqlCommand("select Barcode, ItemID, ShowTitle, Format, Library, ID, ShowID from view_matchShwByRequest WHERE ShowID = @shownum", connsho);
                   commshow.Parameters.AddWithValue("@shownum", appReqsGrid.Columns[4]);

                    appReqsGrid.DataSource = commshow.ExecuteReader();
                    //actualMatchGrid.DataSource = commshow.ExecuteReader();                  
                    actualMatchGrid.AllowSorting = true;
                    actualMatchGrid.AutoGenerateColumns = false;
                    actualMatchGrid.DataKeyNames = new string[] { "ShowID" };

                    BoundField shw1 = new BoundField();
                    BoundField shw2 = new BoundField();

                    shw1.HeaderText = "Record";
                    shw1.DataField = "ShowID";
                    shw1.ReadOnly = true;

                    shw2.HeaderText = "Show";
                    shw2.DataField = "ShowTitle";
                    shw2.ReadOnly = true;

Question by:synergeticsoul
    LVL 96

    Expert Comment

    by:Bob Learned
    If you are trying to get a value from a GridView, then you need to get it from a row's cell, not the column:



    Author Comment

    ok  so would it be this.appReqsGrid.Rows[0].Cells[4]  because it is the 4th cell that I am trying to retrieve the information?
    LVL 96

    Expert Comment

    by:Bob Learned
    That would be my guess, but you are the one who has to tell me.


    Author Comment

    i get the same error:
    No mapping exists from object type System.Web.UI.WebControls.BoundField to a known managed provider native type.

    error on : actualMatchGrid.DataSource = commshow.ExecuteReader();

    Author Comment

    i have to find the value of the selected row from grid 1 and show that value in the select statement for grid 2.

    when i try to put a value on the datagrid, also tried:  int showtheid= appReqsGrid.DataKeys[4];  i also get an error.
    LVL 96

    Accepted Solution

    It sounds like you haven't set up the grid correctly.


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now