Widget BindGrid() - cant delete last entry in grid - bug fix..

Topics: Controls
Jun 16, 2009 at 8:59 PM

Playing about with the LinkList widget, and cant delete the last link in my list. No matter how many times i hit the delete button, the link wont go away!

Problem lies in the BindGrid() method..

Here is a working solution...

 

 

 

private void BindGrid()
{
        XmlDocument doc = Doc();
		XmlNodeList list = doc.SelectNodes("//link");

        if (list.Count > 0)
        {
            using (XmlTextReader reader = new XmlTextReader(doc.OuterXml, XmlNodeType.Document, null))
            {
                System.Data.DataSet ds = new System.Data.DataSet();
                ds.ReadXml(reader);
                grid.DataSource = ds;
                grid.DataKeyNames = new string[] { "id" };
                grid.DataBind();
                ds.Dispose();
            }
        }
        else
        { //BUG FIX to remove last entry in grid
            grid.DataSource = null;
            grid.DataBind();
        }
}

 

Hope thats of some help to someone!!