It would be better if you had
Profile_Controls Table
Profile_Name Controls_Key Controls_Value
-----------------------------------------------------
Lamp_Profile1 ON_OFF ON
Lamp_Profile1 BRIGHTNESS NONE
Fan_Profile1 ON_OFF ON
Fan_Profile1 SPEED NONE
.....
Then you can select
Select Controls_Key+'='+Controls_Value AS Settings From Profile_Controls Where Profile_Name = 'Fan_Profile1'
Results
-----------------
Settings
---------------------
ON_OFF=ON
SPEED=ON
This give you more flexibility as you can filter, JOIN, COMPARE, and use other built-in SQL functionality
If you still want to maintain your table structure like you have it
string[] mysplit = Tool_Tip.Split(s.Split(new string[]{"Controls:"}, StringSplitOptions.RemoveEmptyEntries);
string controls = mysplit[1].Substring(0); //ON_OFF=On;BRIGHTNESS=NONE
string[] eachSettings = controls.Split(';');
//eachSettings[0] = ON_OFF=ON
//eachSettings[1] = BRIGHTNESS=NONE
UPDATE
public System.Data.DataTable GetProfileSettings(string profilename)
{
string sql = "Select Controls_Key+'='+Controls_Value AS Settings From Profile_Controls Where Profile_Name = '"+profilename+"'";
//write ADO.Net code here to get settings into DataTable
//DataTable dt = blah blah blah;
return dt;
}
in your page
protected void SomeEvent_Handler(object sender, EventArgs e)
{
myListBox2.DataSource = GetProfileSettings("FanProfile1");
myListBox2.DataTextField = "Settings";
myListBox2.DataBind();
}
You can use this link as reference for adding item to your listBox How to retrieve commas delimited values in SQL to a ListBox separately
GridViewheaders, it preserves the newlines.