We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Grid with DropDown not udpating (inline edit)

Thread ID:

Created:

Updated:

Platform:

Replies:

95807 Aug 2,2010 12:36 PM Sep 3,2012 09:02 AM ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Brandon Harris
Asked On August 2, 2010 12:36 PM

I've got the grid displaying rows from my SQL table fine, and any edits (inline, just typing xyz, etc..) update fine on the page and the SQL back-end. However, I have a number of fields that need to pull values from the back-end for editing purposes, I can't allow straight text input from a user. So I've created a template with a drowndown box in the row/cell.. See image for code on how I've done this.

The inline editing works fine selecting the values and updating the values from SQL as text, but it won't update when I change the value from the dropdown box. I've also removed any "where" clause from the Update statement to see if it was a parameter issue, and the change was not updated on the page or in SQL after choosing a different value.

So long story short, inline editing works for all fields that are not a dropdown. I can change the cell/field to a dropdown, but using that dropdown to choose a new value doesn't update on the page or on the back-end (via sql).

Any ideas? Let me know if this sounds really confusing and I can try and explain it better.

Thanks!

Brandon





grid_ddl_issue_8e7d164e.zip

Manickam Chidambaram [Syncfusion]
Replied On August 6, 2010 09:17 AM

Hi Brandon,

Thanks for your interest in Syncfusion Products.

I am afraid that I am unable to reproduce the issue reported by you. So could you please provide us more details to reproduce this issue so that we could sort out this issue and provide you the solution?

For your convenience we created a simple sample which uses DropDownList in InlineEdit Mode. The sample can be downloaded from following link.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Grid_InlineFormEdit-720841014.zip


Also we suggest you to refer our online samples from the following link to know more about InlineEdit Mode of Syncfusion Grid grouping Control.

http://samples.syncfusion.com/ASPNET/8.3.0.21/Web/Grid.Grouping.Web/Samples/3.5/CRUDOperations/EditingModes/cs/EditingModes.aspx?args=7

Please try using the above sample and let me know if it helps.

Regards,
Manickam

Fernando
Replied On August 6, 2012 10:57 PM

Hi!
 
  I am using the code you posted in the sample. I have a grid showing products. The products have a field "categorycode" that points to table Categories. The grid has a column for "categoryCode", but I want to display the "Name" field of Categories table in that column. Is it possible to accomplish that using a dropdown column?
 
 I used the same code you posted here:

DropDownList dropdown = new DropDownList();

dropdown.DataSourceID =

"ObjectDataSource1";

dropdown.DataTextField =

"Name";

dropdown.DataValueField =

"Code";

//Here we adding the DropDownListBox programatically using ITemplate Interface
TemplateClass mytemp = new TemplateClass(dropdown);
e.TableCellIdentity.Column.EditItemTemplate = mytemp;
In editing mode, I see the dropdown combo in the line but:
 
 
1- In categorycode column: the lines show the Code instead of the Name
2- when start editing, the combo selected value is not set to the current value of the row (this is, the Products.categoryCode is not looked up in the dropdrowncombo)
3- I select a value in the dropdown, but the column categoryCode doesn't get the value selected by me in the dropdown, it doesnt change.
 
Thanks,
Fernando


grid_and_dropdown_f1ceefb1.zip

Eswari S [Syncfusion]
Replied On September 3, 2012 09:02 AM

Hi Fernando,
 
Thanks for your patience.
 
We have prepared the sample for your reference and the same can be downloaded from the following link:
 
 
Step #1 :  Set the text and value as different for dropdown.
    protected void DropDownList1_Load(object sender, EventArgs e)
    {
        //cast the sender object to dropdownlist object
        DropDownList DDL = (DropDownList)sender;
        //to get distinct companyname values
        AccessDataSource1.SelectCommand = "SELECT Distinct [CompanyName] , [Country] FROM [Customers]";
        DDL.DataSource = AccessDataSource1;
        DDL.DataTextField = "Country";   // text as country
        DDL.DataValueField = "CompanyName";  // value as CompamnyName
        DDL.DataBind();
        //if the current record is not new record
        if (GridGroupingControl1.CurrentTable.CurrentRecord.Kind != DisplayElementKind.AddNewRecord)
        {
            //set the grid current record's companyname to dropdownlist's selectedvalue      
            DDL.SelectedValue = GridGroupingControl1.CurrentTable.CurrentRecord.GetValue("CompanyName").ToString();
        }
    }
Step #2 : Save the text value to the grid column as like below:

protected void GridGroupingControl1_BarButtonItemClicked(object source, Syncfusion.Web.UI.WebControls.Grid.Grouping.ButtonBarItemClickEventArgs e)
    {
        if (e.ButtonBarItem.ButtonBarItemType == ButtonBarItemType.Save )
        {
            Record curRecord = this.GridGroupingControl1.FormEditCell.CurrentRecord;           
            DropDownList ddl = this.GridGroupingControl1.FormEditCell.FindControl("DropDownList1") as DropDownList;          
            curRecord.SetValue("CompanyName", ddl.SelectedItem.Text);   // set text to column instead value
           .  . . . . .
        }
    }   
Please try this and let us know if you need any further assistance.
 
Regards,
Eswari.S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;