Hi,
The scenario is as follows, I have a GridView and on the footer is the "Add" option where I choose a dropdown element to be added to the gridview. like a category selection for the actual element shown.
Now the category list has grown hugue and it is time for using the DNNTextSuggest...
But hey, it looks like it's not working well if it's not placed on the DNN usercontrol root... if we put it inside a gridView as a templated field it doesn't reference it right...
when I type anything appears a javascript popup with the message "404 - control not found"...
We have the following code for the populate on demand event:
protected void DNNTextSuggestCamp_PopulateOnDemand(object source, DotNetNuke.UI.WebControls.DNNTextSuggestEventArgs e) { DNNTextSuggest DNNTextSuggestCtl; DNNTextSuggestCtl = (DNNTextSuggest)((gvAgrupCamp.FooterRow.Cells[3].FindControl("DNNTextSuggestCamp"))); PopulateList(e.Nodes, e.Text, DNNTextSuggestCtl); }
the findcontrol method of referencing the usercontrol is working right with other usercontrols so I think it's a javascript problem of any kind..
I attach the rest of the code at the end of the post, as it might be interesting it is an adaptation to c# of the Michael Washington article. http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1067/Default.aspx
Ah, the code works fine if I reference directly the DNNTextSuggest control on the usercontrol root. protected void MyDNNTextSuggest_PopulateOnDemand(object source, DNNTextSuggestEventArgs e)
{
PopulateList(e.Nodes, e.Text, this.MyDNNTextSuggest);
}
The code: private void PopulateList(DNNNodeCollection objNodes, String strText, DNNTextSuggest DNNTextSuggestCtl) { DNNNode o; DataTable dt = GetData(); String strText2 = strText.Replace("[", "").Replace("]", "").Replace("'", "''"); dt.CaseSensitive = DNNTextSuggestCtl.CaseSensitive;
DataRow[] Drs = dt.Select("name like '" + strText2 + "%'"); foreach (DataRow dr in Drs) { if ((DNNTextSuggestCtl.MaxSuggestRows == 0) || (objNodes.Count < DNNTextSuggestCtl.MaxSuggestRows + 1)) { o = new DNNNode((String)dr["name"]); o.ID = (String)dr["id"]; objNodes.Add(o); } }
} private DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("id", System.Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("name", System.Type.GetType("System.String"))); AddRow(1, "name1", dt); AddRow(1, "name12", dt); AddRow(1, "name1234", dt); AddRow(1, "name13", dt); AddRow(1, "name134", dt); AddRow(1, "name14", dt); AddRow(1, "name125", dt); AddRow(1, "name12345", dt);
return dt; } private void AddRow(int ID, String Name, DataTable dt) { DataRow dr = dt.NewRow(); dr["id"] = ID; dr["name"] = Name; dt.Rows.Add(dr); }
|