Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

From DB to gridview, then compute add result to new column

reppelzreppelz PhilippinesPosts: 3Member

I have a problem, I'd like to get all the values from db and view it all in a Gridview. Once I get the data, I'd like to match the value in the textbox to all rows in gridview/db. Then put the result to the new column in the same/other gridview

TextBox1.Text = Hello Everyone! I'm your.. ;

I only want to know how to match the text in here while using a simple string match in c#

RowId   |   Sentence                |    Percntg Match (newly added column)
  1     |  Hello there! I'm...      |      0.103453
  2     |  Hi there! My name..      |      0.237657
  3     |  Hey dude! How are ...    |      0.15342

I hope you understand what I result I want to get

Comments

  • CaldazarCaldazar BelgradePosts: 1Member

    If I understood you correctly, this could help you. This part of code would pass through all the rows of your GridView, but only through those that are currently visible. If you want to compare all the columns, you would need another foreach inside. Also, if you want to check for absolutely all values (both visible and unvisible rows) you would need to iterate through your DataSource (best to use DataTable for that) instead of iterating through GridView.

    foreach (GridViewRow r in GridView1.Rows)
        {
           if (r.Cells[index].Text == TextBox1.Text) //index would be the column that you want to check value for
           {
              //Do some work here 
           }
      }

    Regards,

Sign In or Register to comment.