I am sorry, I misspoke on the first request, the form view is only in insert mode, so I don't need to exlude a ROW from the form, but specific COLUMNS based on values in another table.
Here is simplified example.
jobType Table has 2 columns, requiresName and requiresDate
the form in question, will be collecting data to go in the jobs table.
When the form is compiled, it will check the jobType tbl to see if the requiresName and requiresDate fields are checked. If they are, those fields should be visible in the form. If they are not checked, those two fields should not be visible on the form and they will be submitted into the jobs table with NULL values.
Here is what I have so far.
if (!Page.IsPostBack)
{
SqlConnection MyConnection;
SqlCommand MyCommand;
SqlDataReader MyReader;
SqlParameter lobParam;
MyConnection = new SqlConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["rdConnectionString"].ConnectionString;
MyCommand = new SqlCommand();
MyCommand.CommandText =
" SELECT * FROM LinesOfBusiness WHERE lobID = @lobID ";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = MyConnection;
lobParam = new SqlParameter();
lobParam.ParameterName = "@lobID";
lobParam.SqlDbType = SqlDbType.Int;
lobParam.Size = 4;
lobParam.Direction = ParameterDirection.Input;
lobParam.Value = "2";
MyCommand.Parameters.Add(lobParam);
MyCommand.Connection.Open();
MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConne ction);
if (MyReader.Read())
{
string codeStr = "";
if (MyReader.GetBoolean(MyReader.GetOrdinal("requires PropAddress")) == true)
//code to set visiblility of form field, this is the part I can't get to work.
}
MyCommand.Dispose();
MyConnection.Dispose();
}
}
|