Note that there are some explanatory texts on larger screens.

plurals
  1. POGridView data to database with validation
    primarykey
    data
    text
    <p>I am begineer of asp.net developer, grid view contain</p> <pre><code>ProductID, ProductName, Price, Qty, Total </code></pre> <p>default set in five column</p> <p>if select the productname then price display automatically,but Qty will be enter the user. if not enter the Qty then display message, if any one column complete fill save the database ?</p> <p>productName is dropdownlist, i need server side code in my code</p> <p>protected void btnSave_Click(object sender, EventArgs e) {</p> <pre><code> SqlDataAdapter sda; SqlCommand cmd; DateTime savedate = DateTime.ParseExact(txtBillDate.Text.Trim() + " " + DateTime.Now.ToString("hh:mm:ss tt"), "dd/MM/yyyy hh:mm:ss tt", null); TextBox txtProductID, txtPrice, txtQty, txtTotal; DropDownList ddlProductName; DataTable mdt = new DataTable(); Label lblGrandTotal; if (DataCheck()) { if (txtMobileNumber.Text != "") { con.Open(); cmd = new SqlCommand("insert into Billing(BillNumber,BillDate,CustomerName,CustomerMobile) values('" + txtBillNumber.Text + "','" + savedate + "','" + ddlCustomerName.SelectedItem.Text + "','" + txtMobileNumber.Text + "')", con); for (int i = 0;i&lt; GridView1.Rows.Count ; i++) { txtProductID = (TextBox)(GridView1.Rows[i].FindControl("txtProductID")); ddlProductName = (DropDownList)(GridView1.Rows[i].FindControl("ddlProductName")); txtPrice = (TextBox)(GridView1.Rows[i].FindControl("txtPrice")); txtQty = (TextBox)(GridView1.Rows[i].FindControl("txtQty")); txtTotal = (TextBox)(GridView1.Rows[i].FindControl("txtTotal")); lblGrandTotal = (Label)(GridView1.Rows[i].FindControl("lblGrandTotal")); sda = new SqlDataAdapter("insert into BillingChild(ProductID,ProductName,Price,Qty,Total,BillNumber,BillDate,CustomerName,MobileNumber,BillChildNumber) values('" + txtProductID.Text + "','" + ddlProductName.SelectedItem + "','" + Convert.ToDecimal(txtPrice.Text) + "','" + Convert.ToDecimal(txtQty.Text) + "','" + Convert.ToDecimal(txtTotal.Text) + "','" + txtBillNumber.Text + "','" + savedate + "','" + ddlCustomerName.SelectedItem + "','" + txtMobileNumber.Text + "','" + txtBillChildNumber.Text + "')", con); sda.Fill(mdt); cmd.ExecuteNonQuery(); } con.Close(); } } else { Response.Write("&lt;Script&gt;alert('plz enter Qty')&lt;/script&gt;"); } } public bool DataCheck() { //TextBox txtProductID = null, txtPrice = null, txtQty = null, txtTotal = null; //DropDownList ddlProductName = null; //Label lblGrandTotal = null; TextBox txtProductID, txtPrice, txtQty, txtTotal; DropDownList ddlProductName; Label lblGrandTotal; if (GridView1.Rows.Count != 0) { for (int i = 0; i &lt; GridView1.Rows.Count; i++) { txtProductID = (TextBox)(GridView1.Rows[i].FindControl("txtProductID")); ddlProductName = (DropDownList)(GridView1.Rows[i].FindControl("ddlProductName")); txtPrice = (TextBox)(GridView1.Rows[i].FindControl("txtPrice")); txtQty = (TextBox)(GridView1.Rows[i].FindControl("txtQty")); txtTotal = (TextBox)(GridView1.Rows[i].FindControl("txtTotal")); lblGrandTotal = (Label)(GridView1.Rows[i].FindControl("lblGrandTotal")); if (txtQty.Text != "") { continue; } else { return false; } } } return true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload