Skip to content

Replies

0
deewakar kumar
deewakar kumar answered on Jun 8, 2015 3:35 PM

Hello Nadia,

There were some db issue at my side that I have corrected and the code is running well now.

I explored many new things through your forum. Thank you and your team for helping me. 

0
deewakar kumar
deewakar kumar answered on Jun 3, 2015 10:30 AM

Hi Nadia,

I am attaching a sample here.Hope this helps you to solve the issue that I am facing.

Thanks..

0
deewakar kumar
deewakar kumar answered on Jun 1, 2015 4:19 PM

Hi Nadia…

Here is my code.I am still getting the same error.When the dropdown column is in editable mode it do not throw error.But it throws  error only when we do not touch the dropdown column and update the value in any other column in the same row..It stores the text in variable " fromCC " in function "UpdateAllocation()" (mentioned below) which is a GUID and hence throws an exception.

 Allocation.aspx

————————  

function dgAllocation_CellEditing_ExitedEditMode(sender, eventArgs) {

           var grid = $find("<%=dgAllocation.ClientID%>");

            var gridBehaviors = grid.get_behaviors();

            var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);

            var rowId = row.get_index();

            abmAPI.updateAllocations(rowId,

                        eventArgs.getCell().get_row().get_cellByColumnKey("AL_ID").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("MI_YEAR").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("CC_NAME").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTTYPE").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTPATTERN").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("AL_DESTPATTERN").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("ST_NUM").get_value(),

                        eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value() != null ? eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value() : "1",

                        updateAllocationsHandler);

        }

 <Behaviors>

                        <ig:EditingCore AutoCRUD="False" BatchUpdating="True">

                            <Behaviors>

                                <ig:CellEditing>

                                    <ColumnSettings>

                                        <ig:EditingColumnSetting ColumnKey="Notes" ReadOnly="True" />

                                        <ig:EditingColumnSetting ColumnKey="MI_YEAR" ReadOnly="True" />

                                        <ig:EditingColumnSetting ColumnKey="CC_ID" ReadOnly="True" />

                                        <ig:EditingColumnSetting ColumnKey="CC_NAME" ReadOnly="False" EditorID="FromCCProvider" />

                                        <ig:EditingColumnSetting ColumnKey="AL_ACCTTYPE" ReadOnly="False" EditorID="FromTypeProvider" />

                                        <ig:EditingColumnSetting ColumnKey="AL_ACCTPATTERN" ReadOnly="False" />

                                        <ig:EditingColumnSetting ColumnKey="AL_DESTPATTERN" ReadOnly="False" />

                                        <ig:EditingColumnSetting ColumnKey="AL_ALLOCTYPE" ReadOnly="False"  />

                                        <ig:EditingColumnSetting ColumnKey="ST_NUM" ReadOnly="False" EditorID="AllocationTypeProvider" ValidatorID="RequiredFieldValidator1" />

                                        <ig:EditingColumnSetting ColumnKey="MI_ID" ReadOnly="False" />

                                        <ig:EditingColumnSetting ColumnKey="NUM_NOTES" ReadOnly="False" />

                                        <ig:EditingColumnSetting ColumnKey="AL_TIMING" ReadOnly="False" />

                                    </ColumnSettings>

                                    <CellEditingClientEvents ExitedEditMode="dgAllocation_CellEditing_ExitedEditMode" />

                                    <EditModeActions EnableOnKeyPress="True" MouseClick="Single" />

                                    <EditModeActions MouseClick="Single" EnableOnKeyPress="True"></EditModeActions>

                                </ig:CellEditing>

                                <ig:RowAdding Alignment="Top" EditModeActions-EnableF2="true" EditModeActions-EnableOnActive="true"

                                    EditModeActions-MouseClick="Single" Enabled="true">

                                    <ColumnSettings>

                                        <ig:RowAddingColumnSetting ColumnKey="Notes" ReadOnly="True" />

                                        <ig:RowAddingColumnSetting ColumnKey="MI_YEAR" ReadOnly="True" />

                                        <ig:RowAddingColumnSetting ColumnKey="CC_ID" ReadOnly="True" />

                                        <ig:RowAddingColumnSetting ColumnKey="CC_NAME" ReadOnly="False" EditorID="FromCCProvider" />

                                        <ig:RowAddingColumnSetting ColumnKey="AL_ACCTTYPE" ReadOnly="False" EditorID="FromTypeProvider" />

                                        <ig:RowAddingColumnSetting ColumnKey="AL_ACCTPATTERN" ReadOnly="False" />

                                        <ig:RowAddingColumnSetting ColumnKey="AL_DESTPATTERN" ReadOnly="False" />

                                        <ig:RowAddingColumnSetting ColumnKey="AL_ALLOCTYPE" ReadOnly="False" />

                                        <ig:RowAddingColumnSetting ColumnKey="ST_NUM" ReadOnly="False" EditorID="AllocationTypeProvider" />

                                        <ig:RowAddingColumnSetting ColumnKey="MI_ID" ReadOnly="False" />

                                        <ig:RowAddingColumnSetting ColumnKey="NUM_NOTES" ReadOnly="False" />

                                        <ig:RowAddingColumnSetting ColumnKey="AL_TIMING" ReadOnly="False" />

                                    </ColumnSettings>

                                    <AddNewRowClientEvents  ExitedEditMode="dgAllocation_CellEditing_ExitedEditMode" />

                                </ig:RowAdding>

                                <ig:RowDeleting Enabled="true" />

                            </Behaviors>

                        </ig:EditingCore>

                        <ig:Activation>

                        </ig:Activation>

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

                        </ig:Selection>

                        <ig:RowSelectors>

                        </ig:RowSelectors>

                    </Behaviors>

Function to Update and Insert(allocid is primary key)

—————————————————–

  private void updateAllocation()

        {

            string output = "";

            try

            {

                string rowId = Request.Form["rowId"].ToString();

                int year = int.Parse(Request.Form["year"].ToString());

                Guid fromCC = new Guid(Request.Form["fromCC"].ToString());

                string fromType = Request.Form["fromType"];

                string fromAccount = Request.Form["fromAccount"];

                string destinationCC = Request.Form["destinationCC"];

                string strAllocType = Request.Form["allocType"].ToString();

                Guid allocType;

                string allocId = Request.Form["allocId"].ToString();

                Guid AL_ID;

                Guid MI_ID = new Guid();

                double al_timing = double.Parse(Request.Form["al_timing"].ToString());

                if (strAllocType.Trim() == "FTE" || strAllocType.Trim() == "null")

                    allocType = new Guid();

                else

                    allocType = new Guid(strAllocType);

                foreach (ModelInstance mi in currentMM.ModelInstances)

                {

                    if (mi.modelInstanceYear == year)

                    {

                        MI_ID = mi.modelInstanceID;

                    }

                }

                AllocationsService svc = new AllocationsService();

                if (allocId == "null")

                {

                    AL_ID = svc.insertAllocation(MI_ID, fromCC, fromType, fromAccount, destinationCC, allocType, al_timing, loggedInUserID);

                    output = rowId + "&&" + AL_ID.ToString();

                }

                else

                {

                    AL_ID = new Guid(allocId);

                    svc.updateAllocation(AL_ID, MI_ID, fromCC, fromType, fromAccount, destinationCC, allocType, al_timing, loggedInUserID);

                    output = "VALID";

                }

            }

            catch

            {

                output = "INVALID";

            }

            finally

            {

                Response.Clear();

                Response.Write(output);

                Response.End();

            }

        }

lB_2_9

0
deewakar kumar
deewakar kumar answered on May 29, 2015 11:33 AM

Actually I needed the selected Row Index. I found the solution in the Forum. Thanks for your reply. I have another question.

I am converting an Ultrawebgrid to Webdatagrid .There are six columns out of which two are dropdown and rest are textbox. During editing a row when I do not select 

any items from the dropdown and update the values of other textboxes it gives me the text of the dropdown instead of value which is a GUID and throws an exception

"Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)". I need the GUID not the text. But when I go to select an item from the dropdown it gives me the value that is GUID. I could not figure out how to resolve it. Please help. Below is my code.

Javascript Code:

function dgAllocation_CellEditing_ExitedEditMode(sender, eventArgs) {
var grid = $find("<%=dgAllocation.ClientID%>");

var gridBehaviors = grid.get_behaviors();
var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);
alert(row);
var rowId = row.get_index();

abmAPI.updateAllocations(rowId,
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ID").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("MI_YEAR").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("CC_NAME").get_value(), ///dropdown
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTTYPE").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_DESTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("ST_NUM").get_value(),    ///dropdown
eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value()!=null?eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value():"1",
updateAllocationsHandler);

}

Dropdown:

<EditorProviders>
<ig:DropDownProvider ID="AllocationTypeProvider">

<EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" TextField="ST_NAME"
ValueField="ST_ID" EnableAnimations="False" EnableDropDownAsChild="False" ClientIDMode="Predictable"
ID="EditorControl1">
<DropDownItemBinding TextField="ST_NAME" ValueField="ST_ID"></DropDownItemBinding>
</EditorControl>
</ig:DropDownProvider>
<ig:DropDownProvider ID="FromTypeProvider">

<EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" EnableAnimations="False"
EnableDropDownAsChild="False" ClientIDMode="Predictable" ID="EditorControl2">
</EditorControl>
</ig:DropDownProvider>
<ig:DropDownProvider ID="FromCCProvider">

<EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" TextField="CC_NAME"
ValueField="CC_ID" EnableAnimations="False" EnableDropDownAsChild="False" ClientIDMode="Predictable"
ID="EditorControl3">
<DropDownItemBinding TextField="CC_NAME" ValueField="CC_ID"></DropDownItemBinding>
</EditorControl>
</ig:DropDownProvider>
</EditorProviders>

 How to update the value in only that cell which are active and set the GUID instead of text of the dropdown?