Hi
I have code like :
In code behind I have :
And the problem is :
If I mach data from database to RadComboBox, the lines witch data disapear after loaded.
If I move RadComboBox outside of RadGrid and insted of :
I call simply :
findCompanyBox.Items.Add(boxItem);
without finding component, everything work well .
Where is the solution ??
Regards
Krzysztof
I have code like :
<telerik:RadGrid ID="GridAdvert" runat="server" PageSize="5" OnItemDataBound="GridAdvert_ItemDataBound" OnNeedDataSource="GridAdvert_NeedDataSource" > |
<MasterTableView DataKeyNames="id" |
EditMode="PopUp"> |
<EditFormSettings EditFormType="Template" PopUpSettings-ZIndex="200"> |
<EditColumn UniqueName="EditCommandColumn1" > |
</EditColumn> |
<FormTemplate> |
<telerik:RadComboBox ID="findCompanyBox" runat="server" Skin="Inox" |
AllowCustomText="True" ShowToggleImage="True" ShowMoreResultsBox="true" |
EnableLoadOnDemand="True" EnableVirtualScrolling="true" |
Width="200px" Height="200px" |
Text='<%# DataBinder.Eval( Container, "DataItem.companyName" ) %>' |
ZIndex="1000" OnItemsRequested="findCompanyBox_ItemsRequested" > |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</telerik:RadComboBox> |
In code behind I have :
RadComboBox FindCompanyBox = new RadComboBox(); |
protected void GridAdvert_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormItem && e.Item.IsInEditMode) |
{ |
GridEditFormItem item = e.Item as GridEditFormItem; |
FindCompanyBox = (RadComboBox)item.FindControl("findCompanyBox"); |
} |
} |
protected void findCompanyBox_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) |
{ |
if (e.Text.Length < 3) return; |
String ConnString = |
"Provider=Microsoft.Jet.OLEDB.4.0;" + |
"Data Source=c:\\DataFile.mdb;" + |
"User Id=admin;Password=;"; |
OleDbConnection conn = new OleDbConnection(ConnString); |
DataSet simData = new DataSet(); |
String query = |
"SELECT id , companyName " + |
"FROM Company " + |
"WHERE UCASE(companyName) LIKE UCASE('%" + e.Text + "%') " + |
"ORDER BY id "; |
OleDbCommand command = new OleDbCommand(query, conn); |
OleDbDataAdapter adapter = new OleDbDataAdapter(command); |
conn.Open(); |
adapter.Fill(simData, "Company"); |
conn.Close(); |
DataTable data = new DataTable(); |
data = simData.Tables[0]; |
int ile = data.Rows.Count; |
try |
{ |
int itemsPerRequest = 10; |
int itemOffset = e.NumberOfItems; |
int endOffset = itemOffset + itemsPerRequest; |
if (endOffset > data.Rows.Count) |
{ |
endOffset = data.Rows.Count; |
} |
if (endOffset == data.Rows.Count) |
{ |
e.EndOfItems = true; |
} |
else |
{ |
e.EndOfItems = false; |
} |
for (int i = itemOffset; i < endOffset; i++) |
{ |
RadComboBoxItem boxItem = |
new RadComboBoxItem(data.Rows[i]["companyName"].ToString(), data.Rows[i]["companyName"].ToString()); |
boxItem.Font.Size = FontUnit.Point(8); |
FindCompanyBox.Items.Add(boxItem); |
} |
if (data.Rows.Count > 0) |
{ |
e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()); |
} |
else |
{ |
e.Message = "No matches"; |
} |
} |
catch |
{ |
e.Message = "No matches"; |
} |
} |
And the problem is :
If I mach data from database to RadComboBox, the lines witch data disapear after loaded.
If I move RadComboBox outside of RadGrid and insted of :
GridEditFormItem item = e.Item as GridEditFormItem; |
FindCompanyBox = (RadComboBox)item.FindControl("findCompanyBox"); |
I call simply :
findCompanyBox.Items.Add(boxItem);
without finding component, everything work well .
Where is the solution ??
Regards
Krzysztof