Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
DropdownProvider in AddRow first item cannot be save in cell if disable CustomValue. How to set custom text on the first item?
posted

Dear Sir/Madam,

I have two dropdownProviders in the WebDatagrid default AddRow at the bottom field. The first dropdownprovide using sqldatasource to bind in the client, and the datasource of 2nd dropdownprovider binded from the server.

I would like to make this two cells as optional field, user can either select the value from the dropdown, or clear the cell/or select item "--None--"

When I set the "EnableCustomValue = false", the first dropdownprovider will show the default 1st item in the list box, however, if the user click the first item, the item cannot be save in the cell, means when you move to another cell, the first cell still showing blank. But this case won't happen if you are not selecting the 1st dropdown item at the 1st time. May I know how to resolve this issue?

I'm thinking if I can bind 1 more extra item call "--None--" show on the 1st row of the list, maybe can solve the issue as well.

But how can I bind this extra Value to the dropdownprovider? I tried the following methods but not working.

1.Set the currentValue in the client  or

2. In server do databound and called in page_load (but this method works fine for 2nd dropdownProvider )

public void drpPrjBU_DataBound(object sender, EventArgs e)

{

DropDownProvider ddlProjBU = (DropDownProvider)this.grd_MHC.EditorProviders.GetProviderById("grd_drpProjBU");

ddlProjBU.EditorControl.Items.Insert(0, new Infragistics.Web.UI.ListControls.DropDownItem("--None--", "0"));

}

3. However, the 2nd dropdownProvider can successfully bind the '--None--' value for the first time only. means the users are not able to select back the --None-- again if they select other item.

----The following is my HTML for your reference---

<ig:WebDataGrid ID="grd_MHC" runat="server" Width="400px" AutoGenerateColumns="False" DataKeyFields="Id" OnRowAdding="grd_MHC_RowAdding" >

<Columns>

<ig:BoundDataField Key="Id" Hidden="true">

</ig:BoundDataField>

<ig:BoundDataField Key="BU">

<Header Text="Project BU">

</Header>

</ig:BoundDataField>

<ig:BoundDataField Key="Project">

<Header Text="Project">

</Header>

</ig:BoundDataField>

<ig:BoundDataField Key="WBS">

<Header Text="WBS">

</Header>

</ig:BoundDataField>

</Columns>

<EditorProviders>

<ig:DropDownProvider ID="grd_drpProjBU">

<EditorControl ClientIDMode="Predictable" DataSourceID="SqlDataSource1" DropDownContainerMaxHeight="200px" EnableAnimations="False" EnableDropDownAsChild="False" TextField="CompanyDesc" ValueField="CompanyCode" DataKeyFields="CompanyCode" runat="server">

<DropDownItemBinding TextField="CompanyDesc" ValueField="CompanyCode" />

</EditorControl>

</ig:DropDownProvider>

<ig:DropDownProvider ID="grd_drpProject">

<editorcontrol dropdowncontainermaxheight="200px" enableanimations="False" enablecustomvalues="False" enabledropdownaschild="False" CurrentValue="0" runat="server" OnItemsRequested="drpProj_OnItemRequested" >

</editorcontrol>

</ig:DropDownProvider>

</EditorProviders>

<Behaviors>

<ig:EditingCore AutoCRUD="False">

<Behaviors>

<ig:RowAdding>

<ColumnSettings>

<ig:RowAddingColumnSetting ColumnKey="BU" EditorID="grd_drpProjBU" />

<ig:RowAddingColumnSetting ColumnKey="Project" EditorID="grd_drpProject" />

</ColumnSettings>

<AddNewRowClientEvents EnteredEditMode="grd_MHC_drpPrjBU_EditedMode"/>

<EditModeActions MouseClick="Single" />

</ig:RowAdding>

</Behaviors>

</ig:EditingCore>

<ig:Selection CellClickAction="Row" RowSelectType="Single">

</ig:Selection>

<ig:RowSelectors>

</ig:RowSelectors>

</Behaviors>

</ig:WebDataGrid>

Please advise and Thanks in advance,

Regards,

BH