Hello!
I've been searching for many eons it seems, to get a solution to something that shouldn't be that hard. i have a radgrid with a formtemplate that saves nicely. On display in the radgrid header are some fields useful to the user but not all data is in the header. on editing a row, there are listboxes that need to bind to the proper id - this is my issue - they don't bind by themselves on edit. Again, the id's for these listboxes are not in the header.
I'm showing a sample of the form here. (i've noticed there are a lot of uses of "Itemid" as the key to the grid and the listbox, but that shouldn't be an issue since they use different data sources.)
So, of the many examples i've come across, this below seems to be the closest to getting what i need done. It works fine when there is no formtemplate. Most of the pieces are in place, but i just can't get my hands on the data in order to tie the listboxes to the data.
What is really frustrating, is that editformitem.DataItem is available in the debugger and shows all the values from the database but I cannot get my hands on them.
I've seen examples making use of GridDataKeyArray DataKeyValues , parentTables, DataRow[] and hashtable but something is just not clicking. The example here crashes on examining the GetDataKeyValue.
Someone's help is greatly appreciated!!!
I've been searching for many eons it seems, to get a solution to something that shouldn't be that hard. i have a radgrid with a formtemplate that saves nicely. On display in the radgrid header are some fields useful to the user but not all data is in the header. on editing a row, there are listboxes that need to bind to the proper id - this is my issue - they don't bind by themselves on edit. Again, the id's for these listboxes are not in the header.
I'm showing a sample of the form here. (i've noticed there are a lot of uses of "Itemid" as the key to the grid and the listbox, but that shouldn't be an issue since they use different data sources.)
<telerik:RadGrid ID="RadGridPlantedPlants" runat="server" ><PagerStyle Mode="NumericPages" AlwaysVisible="true" /><MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ItemId" ><Columns> <telerik:GridBoundColumn UniqueName="anItem" HeaderText="ItemId" DataField="ItemId"> <HeaderStyle Width="60px"></HeaderStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="uName" HeaderText="name" DataField="name"> </telerik:GridBoundColumn> </Columns><EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit ItemId: {0}" CaptionDataField="ItemId" EditFormType="Template" PopUpSettings-Modal="true" FormTableItemStyle-HorizontalAlign="Justify"> <FormTemplate> <table id="TableLayout" cellspacing="3" cellpadding="5" width="340" border="0"> <tr> <td> Location:<br />(Largest geographical area)<br /> <telerik:RadComboBox ID="plantingLocationsCombo" runat="server" DataTextField="name" DataValueField="ItemId" DataSourceID="Objectdata_plantingLocations" Width="200px"> </telerik:RadComboBox> </tr> </table> </FormTemplate></EditFormSettings></MasterTableView><ClientSettings><ClientEvents OnRowDblClick="RowDblClick" /></ClientSettings></telerik:RadGrid>So, of the many examples i've come across, this below seems to be the closest to getting what i need done. It works fine when there is no formtemplate. Most of the pieces are in place, but i just can't get my hands on the data in order to tie the listboxes to the data.
What is really frustrating, is that editformitem.DataItem is available in the debugger and shows all the values from the database but I cannot get my hands on them.
I've seen examples making use of GridDataKeyArray DataKeyValues , parentTables, DataRow[] and hashtable but something is just not clicking. The example here crashes on examining the GetDataKeyValue.
protected void RadGridPlantedPlants_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { GridEditFormItem editFormItem = e.Item as GridEditFormItem; //editFormItem.DataItem in debugger shows everything - but I can't get a handle to it RadComboBox plantingLocationsCombo = (RadComboBox)editFormItem.FindControl("plantingLocationsCombo"); if (editFormItem.ItemIndex != -1) //when = -1 is a new item { plantingLocationsCombo.SelectedValue = editFormItem.GetDataKeyValue("pcat_tbllu_location_id").ToString(); } }}Someone's help is greatly appreciated!!!