I have created a custom webpart that utilizes a series of Drop Downs to filter data (AJAX), and then uses the string created from the "selected values" in the dropdowns (CAML Query) to bind data to a DataGrid control. Where I'm struggling is with the CAML query, because I have more than two parameters/filters in the select command. Can someone answer two questions, for me:
1.) Is the syntax in the following query correct?
2.) If it is correct, why won't the code bind the data to the datagrid like it's supposed to? When I execute this code in the web part, I receive a message stating "One or more field types are not installed properly. Go to the list settings page to delete these fields." I have verified that the field types in the lists in question are correct.
void bindDataGrid()
{
//lblMessage.Text = "";
try
{
string selectedPhaseGate = ddItemsListNames.SelectedValue.ToString();
spDS.List = site.Lists[selectedPhaseGate];
spDS.SelectCommand = "<Query><Where><And><And><Eq><FieldRef Name='ProgramName'/><Value Type='Text'>" + ddProgramNames.SelectedValue.ToString() + "</Value></Eq><Eq><FieldRef Name='Customer'/><Value Type='Text'>" + ddCustomers.SelectedValue.ToString() + "</Value></Eq></And><Eq><FieldRef Name='EndItem'/><Value Type='Text'>" + ddEndItems.SelectedValue.ToString() + "</Value></Eq></And></Where></Query>";
oGrid.DataSource = spDS;
this.oGrid.DataBind();
if (oGrid.Rows.Count > 0)
{
if (this.oGrid.HeaderRow.Cells[7].Style.Value == null)
{
for (int x = 7; x < numCols + 3; x++)
{
this.oGrid.HeaderRow.Cells[x].Style.Value = "writing-mode: tb-rl; filter: FlipH FlipV;";
}
}
}
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
}
Thank you.