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. Image for the cookie policy date

Add CheckBox in dynamic Grid

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



4 Replies

MS Mohamed Suhaib Fahad A. Syncfusion Team 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





CB Carlos Banda 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,



RS Rajarajeswari S Syncfusion Team 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





CB Carlos Banda November 24, 2008 02:54 PM UTC

Thanks, for your help


Loader.
Live Chat Icon For mobile
Up arrow icon