我的面板中有 6 个文本框,但并非所有文本框都会在每次用户提交时填写。如何使用此 LINQ 方法但过滤掉空文本框?
public void LogHB()
{
var myTextBoxes = HashboardPanel.Controls
.OfType<TextBox>()
.Where;
foreach(TextBox txt in myTextBoxes)
{
string hbserial = txt.Text;
try
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["HMT2DBCS"].ConnectionString);
using (SqlCommand command = new SqlCommand("spHBcheckin", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@order_id", txtorder_id.Text);
command.Parameters.AddWithValue("@hbserial", hbserial);
}
}
}
}