Note that there are some explanatory texts on larger screens.

plurals
  1. POnull reference with and if statement c#
    primarykey
    data
    text
    <p>I am just want to check for empty text boxes and change the text the boxes if they are null in RowEditing event. I just can't figure this out. Of course the some of the boxes will be empty when the Grid is populated. The other question is am I placing this in the right event? </p> <p>Here is the row editing event :</p> <pre><code>protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { fill_grid(); //Set the edit index. GridView1.EditIndex = e.NewEditIndex; //Bind data to the GridView control. check_grid_boxes(); GridView1.DataBind(); } </code></pre> <p>Here is the check_grid_boxes Method : </p> <pre><code>protected void check_grid_boxes() { if (gtxtLane.Text == "") { gtxtLane.Text = "0"; } else if (gtxtCarriers.Text == "") { gtxtCarriers.Text = "0"; } else if (gtxtREV.Text == "") { gtxtREV.Text = "0"; } return; } </code></pre> <p>Before you mention Java Script or Jquery. This is a web control and my attempts at using java has not worked. </p> <p>I changed my code to this : </p> <pre><code> protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { fill_grid(); GridView1.EditIndex = e.NewEditIndex; var lane = (TextBox)GridView1.Rows[e.NewEditIndex].FindControl("gtxtLane"); var car = (TextBox)GridView1.Rows[e.NewEditIndex].FindControl("gtxtCarriers"); var badcar = (TextBox)GridView1.Rows[e.NewEditIndex].FindControl("gtxtBadCarriers"); if (String.IsNullOrEmpty(lane.Text)) { lane.Text = "0"; } else if (String.IsNullOrEmpty(badcar.Text)) { badcar.Text = "0"; } else if (String.IsNullOrEmpty(car.Text)) { car.Text = "0"; } GridView1.DataBind(); } </code></pre>
    singulars
    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.
 

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