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.

Dynamic adding a row to GridGroupingControl in ASP.Net

Thread ID:

Created:

Updated:

Platform:

Replies:

99341 May 13,2011 09:32 AM May 25,2011 01:28 AM ASP.NET Web Forms (Classic) 2
loading
Tags: Grouping
Santosh U
Asked On May 13, 2011 09:32 AM

Hi. I am trying to figure out how to dynamically add a record with 3 columns, one of which is a DropDownList, to a GridGroupingControl in ASP.Net. Does a GridGroupingControl in Web support this feature? First record will be hard-coded and others thereafter will be dynamically added.

Thanks in advance.



Christopher Issac Sunder K [Syncfusion]
Replied On May 24, 2011 11:33 AM

Hi Santhosh,

Regret for the delay.

Your query belongs to ASP.Net Grid Team and we have forwarded your query to that team. They will update you the details further.

Appreciate your patience.

Regards,
Christo.


Sridhar N [Syncfusion]
Replied On May 25, 2011 01:28 AM

Hi Santhosh,

Thanks for your interest in Syncfusion products.

Query #1"I am trying to figure out how to dynamically add a record with 3 columns, one of which is a DropDownList"

Your requirement can be achieved by adding the record to grid in button click event using AddNewRecord dynamically. The value for the record is set using SetValue() method.DropDownList can be added as ItemTemplate in QueryCellStyleInfo. Please refer the below code snippet.

[Code behind - C#]

void GridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Category")
{// ItemTemplate Creation.
DropDownList ddl = new DropDownList();
string[] controls = { "Level1", "Level2", "Level3" };
ddl.DataSource = controls;
ddl.DataBind();
ddl.SelectedValue = Convert.ToString(e.Style.CellValue);
TemplateClass temp = new TemplateClass(ddl);
e.TableCellIdentity.Column.ItemTemplate = temp;
}
}
}
//Add button click event for adding record
protected void RecordAdd(object sender, EventArgs e)
{
this.GridGroupingControl1.CurrentTable.AddNewRecord.BeginEdit();
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("ID", 2);
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("Name", "Company2");
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("Category", "Level2");
this.GridGroupingControl1.CurrentTable.AddNewRecord.EndEdit();
}


For your convenience, we have created sample and the same can be downloaded from the following link.

Forum44425044.zip

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N



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.

;