Problem to Gridview row and label

Hi,
As there can be empty value to the list item of DDL, how to avoid the display of "&nbsp" below?
https://dl.dropboxusercontent.com/u/40211031/tt96.png

Can I have details to have the Labels as shown in 1st 2 rows below
https://dl.dropboxusercontent.com/u/40211031/tt97.png

within Gridview?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:
Hi,

1. It will not show "&nbsp" in DropDownList if there are no Items.

Can you post the DropDownList ASPX & code behind?
0
HuaMin ChenProblem resolverAuthor Commented:
Many thanks.
One record within the Gridview is having empty on that column, while there is no empty value to DDL.

Is this the event you want to see?
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //ds = GetDataSet();
            string selVal;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                {
                    DropDownList ddl = (DropDownList)e.Row.FindControl("ddl2");
                    if (ddl == null)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "InfoB", "javascript:alert('Unable to bind Edit row in Grid.');", true);
                        //lb_msg.Text = "Unable to bind Edit row in Grid.";
                        return;
                    }
                    else
                    {
                        if (e.Row.RowIndex >= 0)
                            selVal = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
                        else
                            selVal = "";
                        this.BindDropDown(ddl, selVal);
                    }

                    Label lb_rt = (Label)e.Row.FindControl("Item_rate");
                    ddl.Enabled = true;
                }
                else
                {
                    DropDownList ddl = (DropDownList)e.Row.FindControl("ddl");
                    if (ddl == null)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "InfoB", "javascript:alert('Unable to bind row in Grid.');", true);
                        //lb_msg.Text = "Unable to bind row in Grid." + Convert.ToString(e.Row.RowState);
                        return;
                    }
                    else
                    {
                        if (e.Row.RowIndex >= 0)
                            selVal = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
                        else
                            selVal = "";
                        this.BindDropDown(ddl, selVal);
                    }
                    Label lb_rt = (Label)e.Row.FindControl("Item_rate");

                    ddl.Enabled = false;
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                DropDownList ddl = (DropDownList)e.Row.FindControl("ddl3");
                if (ddl == null)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "InfoB", "javascript:alert('Unable to bind footer row in Grid.');", true);
                    //lb_msg.Text = "Unable to bind footer row in Grid.";
                    return;
                }
                else
                {
                    /*if (e.Row.RowIndex >= 0)
                        selVal = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
                    else*/
                        selVal = "";
                    this.BindDropDown(ddl, selVal);
                }
                Label lb_rt = (Label)e.Row.FindControl("Item_rate");

                ddl.Enabled = false;
            }
        }

Open in new window

0
Lokesh B RDeveloperCommented:
Hi,

Nope this method and ASPX code of Dropdownlist.

this.BindDropDown(ddl, selVal);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.