Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
I am doing result search and in that there are many fields and many records. Now i am able to index all the records and search all the columns and fields. I want to search only the particular column or field. Can you please help me out.
Posted
Updated 21-Apr-16 1:17am
v2
Comments
BillWoodruff 2-Feb-16 1:40am    
Why ?
StM0n 2-Feb-16 1:41am    
*offering a shoulder*

1 solution

1. You are opening 2 table tags here.
2. variable index will always be 1. Not sure why do you have it.

Will something like this help you (not tested at all):

C#
html.Append("<table style=\"border-style:solid\">");
           int fieldCount = reader.FieldCount;

           html.Append("<thead>");
           for (int index = 0; index < fieldCount; index++)
           {
               html.Append("<th>" + reader.GetName(index) + "</th>");
           }

           html.Append("</thead><tbody>");

           while (reader.Read())
           {
               html.Append("<tr>");

               for (int index = 0; index < fieldCount; index++)
               {
                   html.Append("<td>" + reader[index].ToString() + "</td>");
               }
html.Append("</tr>");
           }
           html.Append("</tbody></table>");
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900