if (row.Cells[2].Text.ToString() == " ")
{
txtstreet.Text = string.Empty;
}
Help me out pls. I want to check row.cell[2].Text for null
if (row.Cells[2].Text.ToString() == " ")
{
txtstreet.Text = string.Empty;
}
Help me out pls. I want to check row.cell[2].Text for null
Jump to PostIn my suggestion, you can put label to cell and fill, then check label is empty or not.
Jump to PostWhy can't you do the following?
if (row.Cells[2].Text == null || row.Cells[2].Text.ToString() == " ") { txtstreet.Text = string.Empty; }
Jump to Postwindso0, myCell.Formula? Where are you getting this property from?
In my suggestion, you can put label to cell and fill, then check label is empty or not.
Why can't you do the following?
if (row.Cells[2].Text == null || row.Cells[2].Text.ToString() == " ")
{
txtstreet.Text = string.Empty;
}
//--- myCell is a Cell object
if (myCell.Value == null && myCell.Formula == "")
{
//--- Cell is empty
}
windso0, myCell.Formula? Where are you getting this property from?
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;
}
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;
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.
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;
Thank You.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.