hi, I'm trying to create an application similar to a search engine in asp.net 2.0. I have gathered the results of a single query on my engine, in an array. I need to print these results in a spesific spot in my .asxp page. I dont know if the use of array is right way to follow in this application but anyway how can i print the results for example below the text box and button that exists in my .aspx file. I hope my bad english doesnt make it hard to understand what my problem is. Here is my code and the spot i want to place my results
Loading
kikiPosted Jan 22, 2008, 9:13 AM
Matthew CoxPosted Jan 11, 2008, 5:29 AM
so having said that, simply add a ASP Label control into the table column where you had the letters in bold red lettering.
then you need to write a method in the business logic part of your ASP page that can perform the desired operation.
lastly, set the text of the label in your ASP page to reflect the values you with to display.
Example:
ASP page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
C# code:
using System.Configuration;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Here apply the results in your array to the label in whatever fashion you like
//Note: this is a crude example, I would need to see more of your code to make something better.
object[] queryResults = MagicQueryMachine();
StringBuilder str = new StringBuilder();
foreach (string var in queryResults)
str.Append(var);
//Here is where you set the results of your query to the Label
//Note: This may seem invalid if you are unfamiliar with C# / ASP.NET
//programming. BUT, even though the label is declared in your ASP.NET
//page, it is still considered as part of the same class as the C# code
//Therefore, accessing any methods, attributes, etc... is completely
//valid and necessary.
this.displayLabel.Text = str.ToString();
}
}
Hope that all makes sense. :)
kikiPosted Jan 8, 2008, 6:43 AM