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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add CheckBox in dynamic Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

77663 Nov 12,2008 12:15 AM UTC Nov 24,2008 02:54 PM UTC ASP.NET Web Forms (Classic) 4
loading
Tags: GridGroupingControl
Carlos Banda
Asked On November 12, 2008 12:15 AM UTC

Hi,

I want put checkbox in a grid control like a example in your web page (checkboxtemplate.aspx).
But in my case i add grid control dynamically,
i was read your online documentation, but i don't found an example for this case.
Can you would help me with an example. Please.

I have this code lines:

queryString = string.Format("SELECT top 10 * FROM Table1");
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["xstrconn"].ConnectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
dt.Reset();
dt.Load(reader);
reader.Close();
}


xGrid = new GridGroupingControl();
xGrid.DataSource = dt;
xGrid.ShowGroupDropArea = false;
xGrid.TableDescriptor.AllowNew = false;
xGrid.TableDescriptor.AllowEdit = true;
xGrid.ID = "testGrid";
xGrid.PageSize = 0;


GridColumnDescriptor xColumn;
for (int i = 0; i < 5; i++)
{
xColumn = xGrid.TableDescriptor.Columns[i];

xColumn.MappingName = dt.Columns[i].ColumnName;

xColumn.HeaderText= dt.Columns[i].ColumnName.Replace("_"," ");
}


VS 2008
grid control



Mohamed Suhaib Fahad A. [Syncfusion]
Replied On November 21, 2008 06:31 AM UTC

Hi Carlos,

Thanks for the details.

Adding up the RowBtnTemplate (as in the Checkbox sample), is pretty much simple. Only thing you need to have a class that implements ITemplate and uses CheckBox as the control,

class CheckBoxTemplate : ITemplate {

#region ITemplate Members

public void InstantiateIn(Control container) {
CheckBox cBox = new CheckBox();
cBox.ID = "ck";
cBox.CheckedChanged += new EventHandler(cBox_CheckedChanged);
cBox.AutoPostBack = true;
container.Controls.Add(cBox);
}

void cBox_CheckedChanged(object sender, EventArgs e) {
//Implement the checked changed logic here
CheckBox checkbox = (CheckBox)sender;
GridRow gridrow = (GridRow)checkbox.Parent.Parent;
//implement logic for your code
}


#endregion
}

}

Please check the following sample that illustrates this,

http://www.syncfusion.com/support/user/uploads/F77563-1048181264.zip

Let me know if that helps you out.

Thanks,
Fahad




Carlos Banda
Replied On November 21, 2008 08:18 PM UTC

Hi,

I try download the example, but the link not work, can you post the correct link?

Thanks,


Rajarajeswari S [Syncfusion]
Replied On November 24, 2008 11:24 AM UTC

Hi Carlos,

Sorry for the inconvenience caused.

Please refer the sample from the above link:

http://websamples.syncfusion.com/samples/Grid.Web/6.4.0.15/GGC_Web_CheckBoxTemp/main.htm

Please try this and let us know if this helps you out.

Regards,
Raji




Carlos Banda
Replied On November 24, 2008 02:54 PM UTC

Thanks, for your help


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.

Warning Icon 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.Close Icon

;