Hi
I am using a GridDropDownColumn with AllowAutomaticLoadOnDemand enabled in a radgrid that is using the
NeedDataSource event to bind to my datset. As soon as try to use the dropdown I receive the following error
"There is no assigned datasource. Unable to complete the callback request"
Here is my GridDropDownColumn
Thank you
Fred
<telerik:GridDropDownColumn UniqueName="Account" DataField="accountCode" DropDownControlType="RadComboBox" HeaderText="Account" DataSourceID="AccountDataSource" HeaderStyle-Width="150px" ListTextField="name" ListValueField="code" EnableEmptyListItem="true" AllowAutomaticLoadOnDemand="true" ShowMoreResultsBox="true" ItemsPerRequest="10" AllowVirtualScrolling="true"> </telerik:GridDropDownColumn>
protected void gvPOW_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
GridDataItem item = (GridDataItem)e.Item;
gvPOW.Rebind();
RadComboBox ddlCity = item.FindControl("gvddlPOWCity") as RadComboBox;
RadComboBox ddlProject = item.FindControl("gvddlPOWProject") as RadComboBox;
string city = ddlCity.SelectedValue;
cmd = new SqlCommand("select ProjectName, ProjectId from Projects where CityId =" + ddlCity.SelectedValue, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet("DS");
da.Fill(ds,
"Branches");
ddlProject.DataSourceID =
null;
ddlProject.Items.Clear();
ddlProject.Items.Add(
new RadComboBoxItem("Select Project", "0"));
ddlProject.DataSource = ds;
ddlProject.DataBind();
}
}
I want to bind Project details based on City which was selected in Edit mode.Please help me...
Thanks in advance...
public class StageFilterColumn : GridBoundColumn
{
public StageFilterColumn ()
{
}
protected override void SetupFilterControls(TableCell cell)
{
base.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
DropDownList list = new DropDownList();
list.ID = "list" + this.DataField;
list.AutoPostBack = true;
list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);
cell.Controls.AddAt(0, list);
cell.Controls.RemoveAt(1);
List<string> stagesStringList = GetDistinctStages();
ListItem li0 = new ListItem("All Stages", "-1");
list.Items.Add(li0);
foreach (string stage in stagesStringList)
{
ListItem listItem = new ListItem(stage, stage);
list.Items.Add(listItem);
}
}
void list_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dl = (DropDownList)sender;
GridFilteringItem filterItem = dl.NamingContainer as GridFilteringItem;
if (dl.SelectedItem.Value != "-1")
filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
else
filterItem.FireCommandEvent("Filter", new Pair("NoFilter", this.UniqueName));
}
//RadGrid calls this method when the value should be set to the filtering input control(s)
protected override void SetCurrentFilterValueToControl(TableCell cell)
{
base.SetCurrentFilterValueToControl(cell);
DropDownList list = (DropDownList)cell.Controls[0];
if (this.CurrentFilterValue != string.Empty)
{
list.SelectedValue = this.CurrentFilterValue;
}
}
//RadGrid calls this method to extract the filtering value from the filtering input control(s)
protected override string GetCurrentFilterValueFromControl(TableCell cell)
{
DropDownList list = (DropDownList)cell.Controls[0];
return list.SelectedValue;
}
protected override string GetFilterDataField()
{
return this.DataField;
}
}
I am also filtering on other columns where the user types something and then tabs away from the text box and it does an auto postback to filter the data but it returns no data at all. If I filter by my custom column then it is fine. If I filter by my custom column and then filter by any other column it also works as expected.
When I filter by any other column the first time (this is when no data is returned when I know it should be) I looked at the filter expression and basically it is something like this (if (column1Filter == "criteriaIEntered" && customFilterColumn = "-1"). I believe the second bit customFilterColumn = "-1" causes the problem even though I am not filtering by this.

var
column = null;
function MenuShowing(sender, args) {
if (column == null)
return;
var menu = sender;
var items = menu.get_items();
if (column.get_dataType() == "System.String") {
var i = 0;
while (i < items.get_count()) {
if (!(items.getItem(i).get_value() in { 'NoFilter': '', 'Contains': '', 'DoesNotContain': '', 'StartsWith': '', 'EndsWith': '', 'NotEqualTo': '', 'EqualTo': '' })) {
var item = items.getItem(i);
if (item != null)
item.set_visible(
false);
}
else {
var item = items.getItem(i);
if (item != null)
item.set_visible(
true);
}
i++;
}
}
if (column.get_dataType() == "System.Int64") {
var j = 0;
while (j < items.get_count()) {
if (!(items.getItem(j).get_value() in { 'NoFilter': '', 'GreaterThan': '', 'LessThan': '', 'NotEqualTo': '', 'EqualTo': '', 'Contains': '', 'DoesNotContain': '', 'StartsWith': '', 'EndsWith': '' })) {
var item = items.getItem(j);
if (item != null)
item.set_visible(
false);
}
else {
var item = items.getItem(j);
if (item != null)
item.set_visible(
true);
}
j++;
}
}
if (column.get_dataType() == "System.Boolean") {
var j = 0;
while (j < items.get_count()) {
if (!(items.getItem(j).get_value() in { 'NoFilter': '', 'EqualTo': '' })) {
var item = items.getItem(j);
if (item != null)
item.set_visible(
false);
}
else {
var item = items.getItem(j);
if (item != null)
item.set_visible(
true);
}
j++;
}
}
column =
null;
}
function filterMenuShowing(sender, eventArgs) {
column = eventArgs.get_column();
}
<telerik:RadGrid runat="server" Width="580px" Height="350px" Style="margin: 7px 0px 0px 7px;"
ID="grdDelegation" AutoGenerateColumns="False" AllowPaging="True" GridLines="None"
PageSize="5" AllowFilteringByColumn="true"
<
ClientSettings EnablePostBackOnRowClick="true" AllowColumnsReorder="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True" />
<ClientEvents OnFilterMenuShowing="filterMenuShowing" />
</ClientSettings>
<GroupingSettings CaseSensitive="false" />
<FilterMenu OnClientShown="MenuShowing" />
<HeaderStyle Font-Bold="true" HorizontalAlign="Center" />