【发布时间】:2020-11-26 19:24:43
【问题描述】:
我的面板中有 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);
}
}
}
}
【问题讨论】:
-
“LINQ 操作”是什么意思?您的代码无法编译 -
.Where;是什么?
标签: c# linq textbox controlcollection