locked
Gridview RRS feed

  • Question

  • User-1499457942 posted

    Hi

       I am adding record to gridview like below . I want if particular field is blank that row should not be added

    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    
                DataTable dt = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    gvw.DataSource = dt;
                    gvw.DataBind();
                }

    Thanks

    Monday, August 6, 2018 7:49 AM

Answers

  • User753101303 posted

    Hi,

    Seems you should add an additioanl WHERE criteria to your cmd query ? Something like WHERE MyCol IS NOT NULL or WHERE MyCol<>''. Have you tried ?

    I suspect maybe some other issue as wiht that many posts you should be familiar with https://www.w3schools.com/SQl/sql_where.asp

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 6, 2018 8:05 AM