0
if (row.Cells[2].Text.ToString() == " ")
            {
                txtstreet.Text = string.Empty;
            }

Help me out pls. I want to check row.cell[2].Text for null

Edited by __avd: Added [code] tags.

4
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by Moss ali
0

In my suggestion, you can put label to cell and fill, then check label is empty or not.

0

Why can't you do the following?

if (row.Cells[2].Text == null || row.Cells[2].Text.ToString() == " ")
{
    txtstreet.Text = string.Empty;
}
0

//--- myCell is a Cell object

if (myCell.Value == null && myCell.Formula == "")
{
//--- Cell is empty
}

0

Thanks dudes for nice suggestion but my problem is still there i have a dropdownlist which is populated from Province table.In GridView SelectedIndexChanging When i select the row then it fill all the texboxes and dropdownlist.Problm is that if in Province field is null then it throws exception.
Exception:
'ddlstate' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value.
On Populating DrodownList i use this approch.
ddlstate.Items.Insert(0, "--Select Province--");
GridView Code SelectedIndexChanging

if (row.Cells[9].Text == null || row.Cells[9].Text.ToString() == " ")
                
            {
                ddlstate.SelectedIndex = -1;
            }
            else
            {
                ddlstate.SelectedValue = row.Cells[9].Text;
            }

Edited by __avd: Added [code] tags.

0

The value property and the text property are 2 different things. Are you sure you don't need to actually get the Text and not the Value?

ddlstate.Items.FindByText(row.Cells[9].Text).Selected;
0

Dude that line of code gives error
ddlstate.Items.FindByText(row.Cells[9].Text).Selected;
Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement.

0

Sorry, I forgot to complete your code. You realize that Intellesnse tells you what are properties and what are methods in the list that comes up right?

ddlstate.Items.FindByText(row.Cells[9].Text).Selected = true;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.