• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

error on datagrid- unknown webcontrol error

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]);


                    commshow.Connection.Open();
                    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;
  actualMatchGrid.Columns.Add(shw1);
                    actualMatchGrid.Columns.Add(shw2);
actualMatchGrid.DataBind();
                    commshow.Connection.Close();

0
synergeticsoul
Asked:
synergeticsoul
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
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:

this.appReqsGrid.Rows[0].Cells[0]

Bob
0
 
synergeticsoulAuthor Commented:
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?
0
 
Bob LearnedCommented:
That would be my guess, but you are the one who has to tell me.

Bob
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
synergeticsoulAuthor Commented:
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();
0
 
synergeticsoulAuthor Commented:
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.
0
 
Bob LearnedCommented:
It sounds like you haven't set up the grid correctly.

Bob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now