Displaying a list of hyperlink from database with c#/asp.net
<p>I'm an asp.net / c# newbie and i'm trying to create a very simple menu that is generated from my database.
so far i have managed to extract the table from database and into a data table and from there to an array.</p>

<p>My problem is that i haven't figured out how to use the data in a loop in my page (the menu changes according to user types).
I tried using <code>&lt;% =Array %&gt;</code> but i can't seem to use that inside a while/for loop or even assignment line.</p>

<p>Maybe i'm attacking this the wrong way , i guess my question is basically this:
How can i use the data i gather from the database (names , urls) in my dynamic page?</p>

<p>here is my current code behind:</p>

<pre><code>    public string[] keep = new string[100];
public void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //Response.Write("response in postback");
        getMenu();
    }
}

void getMenu()
{
    Response.Write("response in getmenue");
    SqlConnection con = new SqlConnection();
    con.ConnectionString = "server=(local);database=PhilipsMaterials;Integrated Security=SSPI;";
    con.Open();
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    string sql = "Select * from Materials";
    SqlDataAdapter da = new SqlDataAdapter(sql, con);
    da.Fill(ds);
    dt = ds.Tables[0];
    DataRow[] drowpar = dt.Select();
    int i = 0;
    foreach (DataRow dr in drowpar)
    {
        keep[i] = dr["Material Name"] as string;
        i = i + 1;
    }

    con.Close();

}
</code></pre>

<p>Thank you.</p>
