나는 2 개의 필드 속성, 값 및 3 개의 텍스트 상자가있는 gridview 있습니다. 값을 입력 할 때 일부 텍스트 상자를 비워 두었습니다. 빈 textboxes를 확인해야합니다. 빈 값은 데이터베이스에 삽입하고 싶지 않습니다. 이 문제를 어떻게 해결할 수 있습니까 ???asp.net에서 텍스트 상자의 비어 있음을 확인하는 방법은 무엇입니까?
이것은
foreach (GridViewRow gvr in GridView1.Rows)
{
string strcon1;
strcon1 = ConfigurationManager.ConnectionStrings["fwma_devConnectionString"].ConnectionString;
SqlConnection con1 = new SqlConnection(strcon1);
con1.Open();
SqlCommand com3 = new SqlCommand(strcon);
TextBox tb = (TextBox)gvr.FindControl("TextBox2");//value
string txt = tb.Text;
Label propertylabel = (Label)gvr.FindControl("Label4");//id-property
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,[Values]) values('" + propertylabel.Text + "','" + B_id.Text + "','" + tb.Text + "')";
com3.Connection = con1;
com3.ExecuteNonQuery();
con1.Close();
if (tb.Text == String.Empty)
{
}
}
이 비어있을 때 몇 가지 경고를 표시해야합니까? 삽입을 중단 하시겠습니까? – Fals
그냥 빈 텍스트 상자 삽입을 중단하고 싶습니다. 경고를 표시하고 싶지 않습니다. –
'insert' 쿼리가 아니라 'insert'쿼리 전에'null' 또는'Empty'를 확인하십시오. – Rahul