How can I make a column as DropDownList using DropDownProvider in RowEditingTemplate? The sample shows the DropDownList in edit mode within the cell https://ko.infragistics.com/samples/aspnet/data-grid/dropdown-editors
Hello Ram,Thank you for posting your inquiry to the Infragistics ASP.Net forums. To embed a WebDropDown in the WebDataGrid RowEditTemplate, add the WebDropDown control to the RowEditTemplate for the Column where you want the DropDownList to display. Set the DisplayMode to "DropDownList", the TextField to the Name of the Column to display in the WebDropDown, the ValueField to the Column Key which the WebDropDown is bound to, and EnableDropDownAsChild to "true". The Z-Index for the DropDown needs to be set to a higher value or the DropDownList will not display properly. To do this, you can set the Z-Index in the Client-Side Initialize event to a new Z-Index value.
In the Behaviors of the EditingCore, under ColumnSettings, set the ColumnKey to the Column where the WebDropDown was added.
In the RowEditTemplate under the ClientBindings, the RowEditingClientBinding for the Column with the WebDropDown needs to use the $find command to locate the WebDropDown control so its current value may be retrieved and to also set its new value.
The following Markup Code is based on three of the columns from the sample in our Samples Browser which you had referenced in your post. This code will demonstrate how to embed a WebDropDown in a WebDataGrid RowEditTemplate:
<ig:WebDataGrid ID="dg" runat="server" Height="500px" width="800px" DataSourceID="Orders" DataKeyFields="OrderID" AutoGenerateColumns="False" OnRowUpdating="dg_RowUpdating"> <Columns> <ig:BoundDataField DataFieldName="OrderID" Key="OrderID"> <Header Text="Order ID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ContactName" Key="CustomerID"> <Header Text="Contact Name" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ShippingCompany" Key="ShipperID"> <Header Text="Shipper" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing Enabled="true" > <ColumnSettings> <ig:EditingColumnSetting ColumnKey="ShipperID" /> </ColumnSettings> </ig:CellEditing> <ig:RowDeleting Enabled="true" /> <ig:RowEditingTemplate CancelButton="buttonCancel" OKButton="buttonOK"> <ClientBindings> <ig:RowEditingClientBinding ColumnKey="OrderID" ControlID="control_OrderID" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> <ig:RowEditingClientBinding ColumnKey="CustomerID" ControlID="control_ContactName" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> <ig:RowEditingClientBinding ColumnKey="ShipperID" ControlID="control_Shipper" GetValueJavaScript="$find({ClientID}).get_currentValue()" SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" /> </ClientBindings> <Template> <div style="background-color:white;border:1px solid black; height:auto; width:auto"> OrderID: <asp:TextBox ID="control_OrderID" runat="server"/> <br /> ContactName: <asp:TextBox ID="control_ContactName" runat="server"/> <br /> Shipper: <ig:WebDropDown ID="control_Shipper" DisplayMode="DropDownList"DataSourceID="Shippers" TextField="CompanyName" ValueField="ShipperID" runat="server" Width="200px" EnableDropDownAsChild="true" ClientEvents-Initialize="setZIndex"DropDownItemBinding-TextField="CompanyName" DropDownItemBinding-ValueField="ShipperID"> </ig:WebDropDown> <br /> <asp:Button ID="buttonOK" runat="server" OnClientClick="return" Text="OK" UseSubmitBehavior="False" /> <asp:Button ID="buttonCancel" runat="server" CausesValidation="False" OnClientClick="return" Text="Cancel" UseSubmitBehavior="False" /> </div> </Template> </ig:RowEditingTemplate> <ig:RowAdding Enabled="False"> <EditModeActions EnableOnActive="True" EnableOnKeyPress="True" MouseClick="Single" /> </ig:RowAdding> </Behaviors> </ig:EditingCore> <ig:Activation /> <ig:RowSelectors /> <ig:Selection RowSelectType="Single" /> </Behaviors></ig:WebDataGrid>
The following code snippet is an example on how to set the zIndex for the DropDownList of the WebDropDown:
function setZIndex(sender, args) { sender.behavior.set_zIndex(100000);}
Please let me know if this information is helpful or if you have any questions or need further assistance.
Thank you.
Sincerely,Mike D.Developer Support EngineerInfragisticswww.infragistics.com/support
Thanks Mike, I got your sample to work.
I see the edit window flickering on hovering over the WebDropDown control and the down arrow is not shown. I am using Infragistics 2010 Vol.2. Is there any solution or fix for it?
What would be the client bindings - GetValueJavaScript and SetValueJavaScript for a regular ASP.Net DropDownList control, if I have to use instead of Infragistics WebDropDown control?
How can we populate the ASP.Net DropDownList or Infragistics WebDropDown within the <RowEditingTemplate> from code-behind and by not using SqlDataSource design control?
I would appreciate your response!
Hello Ram,
The flickering of the WebDropDown DropDownArrow when its hovered or pressed is because the igdd_DropDownButtonHover and igdd_DropDownButtonPressed images need to be added to the images directory in the ig_res folder of the application.
These images may be found in the Infragistics NetAdvantage ASP.Net Style Libraries for 2010 Volume 2 under the following path:
<C:\Documents and Settings\All Users\Documents\Infragistics\NetAdvantage 2010.2\ASP.NET\StyleLibraries>
Once in this directory, select the directory for the style of your application.
To populate the WebDropDown from the Code Behind, please take a look at our Samples Browser where samples and code may be found under the WebDropDown control for DataBinding using different scenarios. Our Samples browser may be found at the following link:<https://ko.infragistics.com/samples/aspnet>
Please let me know if this information is helpful.Thank you.Sincerely,Mike D.Developer Support EngineerInfragisticswww.infragistics.com/support
Thanks Mike, I could fix the flickering by copying the images.
I would re-phrase my question about the WebDropDown. How can I access/find the WebDropDown control added in the <RowEditingTemplate> from code-behind? If I can find the WebDropDown then I know how to bind it with a DataSet/DataTable.
Please let me know if you need more information. Thanks
The following code demonstrates how to retrieve the embedded WebDropDown by its ID in the WebDataGrid RowEditTemplate using the FindControl method in the server-side WebDataGrid DataBound event:
protected void dg_DataBound(object sender, EventArgs e){ var ram = dg.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("WebDropDown ID");}Please let me know if this helps.Sincerely,Mike D.Developer Support EngineerInfragisticswww.infragistics.com/support
Hi mike ,
i have same requirement i.e i have to use infragistc webgrid with dropdown list, and calendar controls
just like in http://samples.infragistics.com/2010.2/WebFeatureBrowser/Default.aspx
1.But i need bind data for grid and dropdowns inside grid from code behind not in markup(aspx), how i have to do.Usualy for asp.net grids we can find controls inside grid in rowbound event and bind data source ,but for infragistice ho wto find controls inside grid, i tried it , i failed , i need sample which will bind data in code behind
2.How to manipulate grid in code behind which willl save all rows at a tiime when user clicks on save
like foreach gridrow in gridview i have to save
3.Add new row,update behaivors are not working if grid has controls like in dropdown ,buttons ,calander in grid (i tried as part of edit behaivor also) , i failed
please do need ful
Regards
showkath
Hi Mike,
This thread was just what I was looking for to be able to put a WebDropDown control in a RowEditingTemplate. Thank you. However, I've noticed a behavior when using the control where the previously selected value remains selected (either highlighted or the background is grayed).
Given In the screen shoot, when I selected the highlighted row, the value of 'Michigan' was replaced with the last value that I selected which is 'Arizona' from the previous row. Also notice that "Albuquerque', 'Arizona', 'Boise' and the row under 'Cascades' are either selected or the background is grayed. They were also selected for rows towards the top of the grid.
Below is the code used in the markup and the codebehind
<ig:RowEditingClientBinding ColumnKey="Territory" ControlID="control_Territory" GetValueJavaScript="$find({ClientID}).get_selectedItem().get_value()" SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" />
<div class="lbl"> Territory: </div> <ig:WebDropDown ID="control_Territory" DisplayMode="DropDownList" DataSourceID="SqlDataSource2" TextField="mktgrpname" ValueField="mktgrpname" runat="server" Width="250px" EnableDropDownAsChild="true" ClientEvents-Initialize="setZIndex" DropDownOrientation="Default" DropDownItemBinding-TextField="mktgrpname" DropDownItemBinding-ValueField="mktgrpname"> </ig:WebDropDown></div>
Protected Sub GridView_RowSelectionChanged(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.SelectedRowEventArgs) Handles GridView.RowSelectionChanged
Dim DDLB As WebDropDown = _ TryCast(GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("control_Territory"), WebDropDown) If Not IsNothing(DDLB) Then If e.CurrentSelectedRows.Count > 0 Then DDLB.ClearSelection() DDLB.SelectedItemIndex = -1 DDLB.DataBind() DDLB.CurrentValue = e.CurrentSelectedRows.Item(0).Items(14).Value DDLB.SelectedValue = e.CurrentSelectedRows.Item(0).Items(14).Value End If End If
End Sub
What do I need to do to have all previously selected entries deselected (not highlighted and the background white) and highlight the currently selected rows entry highlighted?
Thanks in advance.