I have a SQL query which retrieves two columns from a table based on a 'location'.
The following table:
content_id content_title
234 Fink, James
90 Merylou, Jane
45 Marcy, Kim
112 Bower, John
34 Alset, Mike
was generated by the following query:
DECLARE @strLocation varchar(200)
SET @strLocation = 'Ridge'
SELECT [content_id], [content_title]
FROM [content]
WHERE [folder_id] = '188'
AND (content_html LIKE '%'+@strLocation+'%')
The query looks into the content_html column and looks for the variable.
My HTML looks like this:
<input type=text size=50 id="txtPhysByLoc" runat="server" /><input type=button value="Go" />
<br />
<div>
<table border=0>
<span id="writeTable"></span>
</table>
</div>
My C# code-behind so far looks like this:
protected void Page_Load(object sender, EventArgs e)
{
string cString = "Provider=sqloledb;Data Source=myServer;Initial Catalog=Dbase;User Id=efv;Password=st@tl;";
SqlConnection Conn = new SqlConnection(ConnectionString);
Conn.Open();
}
How can I use the query along with my C# code to generate a table? Or use another ASP.net control to show the tabular data?
GridView, put that in ASPX page, in code behind execute your command, get a result set back in DataTable and then bind it to the GridView.;for each line?