From DB to gridview, then compute add result to new column - Programmers Heaven

Howdy, Stranger!

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


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


  • 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 


Sign In or Register to comment.