Tim Maxey .NET Technology Blog & Resources

December 2007 Entries

Cool effect for Checkbox List

I was messing around with the checkbox list want simulate a dropdown list with checkboxes in it. A buddy of mine said to try the checkbox list inside a div with scroll bars. Well I did not like the scroll bar on the bottom (horizontal). So I found this: <div style="width:300px;height:100px;overflow-x: hidden;overflow-y:scroll;overflow:-moz-scrollbars-vertical !important;"> CHECKBOX LIST HERE </div> Note the !important is a css hack to tell the browser which tag to use depending upon Firefox or IE.... Cool at any rate, works like a champ... Then when a user "checks" the checkbox for one or more selections, you can stick the list in...

VB CreateDataset

This function is passed the string connection for VB.NET Public Function CreateDataSet(ByVal strSQL As String, ByVal strSQL_Connection As String) As Data.DataSet         Dim scnnNW As New System.Data.SqlClient.SqlConnection(strSQL_Connection)         ' A SqlCommand object is used to execute the SQL commands.         Dim scmd As New System.Data.SqlClient.SqlCommand(strSQL, scnnNW)         ' A SqlDataAdapter uses the SqlCommand object to fill a DataSet.         Dim sda As New System.Data.SqlClient.SqlDataAdapter(scmd)         ' Create and Fill a new DataSet.         Dim ds As New Data.DataSet         sda.Fill(ds)         scnnNW.Close()         scnnNW.Dispose()         Return ds     End Function

Dataset Function C#

// ########### START CODE ######################################         public DataSet CreateDataSet(string strSQL)         {             System.Data.SqlClient.SqlConnection scnnNW = new System.Data.SqlClient.SqlConnection(GetConnectionString("connYourConnection"));             // A SqlCommand object is used to execute the SQL commands.             System.Data.SqlClient.SqlCommand scmd = new System.Data.SqlClient.SqlCommand(strSQL, scnnNW);             // A SqlDataAdapter uses the SqlCommand object to fill a DataSet.             System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(scmd);             // Create and Fill a new DataSet.             DataSet ds = new DataSet();             sda.Fill(ds);             scnnNW.Close();             scnnNW.Dispose();             return ds;         } // ########### END CODE ###################################### This function is used to get the connection form the .config file... // ########### START CODE ###################################### static string GetConnectionString(string name)         {             // Assume failure.             string returnValue = null;             // Look for the...

For Loop in C#

Wanted to post a for loop in a dataset, I will post the dataset function as well... foreach (DataRow dr in ds.Tables[0].Rows)             {                 //do something with the data                 if (dr["Field1"] = 1)                 {                       //do something                 }                 else if (dr["Field2"] = 1)                 {                       //do something                 }                 else if (dr["Field3"] = 1)                 {                       //do something                 }                             }