Hi.
I have a grid with a combobox that use OnItemsRequested, to get only the values that is not already in the grid. But the problem is that i can not get a record in edit mode when using OnItemsRequested. If I instead use the combobox datasource, the edit mode works fine but then i get all the values from the database table. In edit-mode the user should not have the possibility to change the value and thee combobox will be disabled. (The OnItemsRequeste methode will not fill the combobox values with the choosen value from insert.) So how can i work it out?
The following code i am using is:
I have a grid with a combobox that use OnItemsRequested, to get only the values that is not already in the grid. But the problem is that i can not get a record in edit mode when using OnItemsRequested. If I instead use the combobox datasource, the edit mode works fine but then i get all the values from the database table. In edit-mode the user should not have the possibility to change the value and thee combobox will be disabled. (The OnItemsRequeste methode will not fill the combobox values with the choosen value from insert.) So how can i work it out?
The following code i am using is:
protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
var users = MtUserAccountBiz.GetMtUserWithNoAccountMapping();
var comboBox = (RadComboBox)sender;
comboBox.Items.Clear();
foreach (var user in users)
{
var item = new RadComboBoxItem();
item.Text = user.UserNumber + " " + user.FirstName + " " + user.LastName;
item.Value = user.UserNumber.ToString();
comboBox.Items.Add(item);
}
}
<Columns>
<telerik:GridTemplateColumn UniqueName="UserNumber" DataField="UserNumber" HeaderText="Bruker" >
<ItemTemplate><%#DataBinder.Eval(Container.DataItem,"UserNumber")%></ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox DataTextField="UserNumber" DataValueField="UserNumber" EnableLoadOnDemand="True" ID="RadComboBox1" HighlightTemplatedItems="true"
runat="server" Height="160px" Width="220px" SelectedValue='<%#Bind("UserNumber") %>'
OnItemsRequested="RadComboBox1_ItemsRequested" AutoPostBack="true">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridNumericColumn DataField="Account" HeaderText="Reskontro" UniqueName="Account"> </telerik:GridNumericColumn>
<telerik:GridEditCommandColumn CancelText="Avbryt" EditText="Endre" InsertText="Sett inn" UpdateText="Oppdater"></telerik:GridEditCommandColumn>
</Columns>