This is a migrated thread and some comments may be shown as answers.

On grid update not passing through dropdown value

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan Vogt
Top achievements
Rank 1
Brendan Vogt asked on 09 Jul 2008, 10:46 AM
Hi,

I am updating from the frid to an XML file.  The first column is a dropdown list.  I copied this code directly from one of the online demos.  For some or other reason it is not passing the value of the value of the selected drop down list.  It is the element called StoreLocatorID.

protected void rgDeposits_UpdateCommand(object source, GridCommandEventArgs e)
{
   GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
   Hashtable ht = new Hashtable();
   gridEditFormItem.ExtractValues(ht);

   String _DepositID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["DepositID"].ToString();

   XmlNode node = dsDeposits.GetXmlDocument().SelectSingleNode(String.Format("Deposits/Deposit[@DepositID='{0}']", _DepositID));

   node.Attributes["StoreLocatorID"].Value = ConvertNullToEmpty(ht["StoreLocatorID"]);
   node.Attributes["CurrentAccountNumber"].Value = ConvertNullToEmpty(ht["CurrentAccountNumber"]);
   node.Attributes["BranchNo"].Value = ConvertNullToEmpty(ht["BranchNo"]);
   node.Attributes["ClientCITNo"].Value = ConvertNullToEmpty(ht["ClientCITNo"]);
   node.Attributes["DateOfDeposit"].Value = ConvertNullToEmpty(ht["DateOfDeposit"]);
   node.Attributes["DepositReferenceInput"].Value = ConvertNullToEmpty(ht["DepositReferenceInput"]);
   node.Attributes["DepositAmount"].Value = ConvertNullToEmpty(ht["DepositAmount"]);

   try
   {
      dsDeposits.Save();
   }
   catch (Exception ex)
   {
      Response.Write(ex.Message);
   }
}

private String ConvertNullToEmpty(Object obj)
{
   if (obj == null)
   {
      return String.Empty;
   }
   else
   {
      return obj.ToString();
   }
}

Please can someone help me?

Thanks
Brendan

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 09 Jul 2008, 02:48 PM
Hi Brendan,

How do you bind your dropdown list to the data field it is used for updating? When ExtractValues() method is used, only values from editors that are bound to a data field are extracted. Is your dropdownlist inside a GridTemplateColumn, or a GridDropDownColumn?

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Brendan Vogt
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or