|
-
February 22nd, 2008, 06:38 PM
#1
Loop through database results and display
Hello,
I need some help getting a button into my results that i have SELECTED from a Table. I would like to be able to add a button, so if there was 10 results their would be 10 buttons; 1 in each row. I dont need any onclick events right now as i can sort that later, i just need to position the button, i have tried but it just errors.
Here is the code so far, i have marked where i would like the button.
Button -
Code:
private void InitializeMyButton()
{
Button button1 = new Button();
button1.Text = "Button";
Controls.Add(button1);
}
SQL Loop
Code:
private void form_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<body bgcolor='#f0f0f0'><font size='1pt'><table><tr><td>Name</td><td>Description</td><td>Preview</td><td>Button</td></tr>");
MySqlConnection myConnection = new MySqlConnection();
myConnection.ConnectionString = "*******";
myConnection.Open();
string mySelectQuery = "SELECT * FROM tabe";
MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
MySqlDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
sb.AppendLine("<tr><td>" + myReader.GetString(0) + "</td><td>" + myReader.GetString(1) + "</td><td><img src='" + myReader.GetString(2) + "'/></td><td>" //BUTTON HERE\\"</td></tr>");
string load = myReader.GetString(3);
}
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
sb.AppendLine("<table/></font></body>");
webBrowser1.DocumentText = sb.ToString();
}
}
}
I get errors like the + is not valid with void or string.
Thanks, PS - im using the latest .NET Framework
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|