Free Support Forum - aspose.com

Aspose.Web.Grid add a checkbox/dropdownlist to cell

Hi,

We have a need to add a checkbox or dropdownlist to a cell in the Aspose.Grid.Web. Does the WebGrid support this functionality? If yes, can you please tell me how to do it?

Thanks,

Vineet

Hi Vineet,

Well, you may add checkbox and dropdown list controls to the worksheet cells as validation types, check the following codes:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
GridWeb1.ForceValidation = true;
WebWorksheet worksheet = GridWeb1.WebWorksheets[0];
WebCells cells = worksheet.Cells;
//Apply CheckBox validation.
WebCell cell1, cell2;
cell1 = cells["B2"];
cell1.StringValue = "Check\n the Box";
cell1.Style.Wrap = true;
cell2 = cells["C2"];
cell2.CreateValidation(ValidationType.CheckBox, true);
GridWeb1.MaxColumn = 35;
GridWeb1.MaxRow = 200;

// DropDownList.
WebCell cell = cells["E2"];
cell.CreateValidation(ValidationType.DropDownList, true);
cell.Validation.ValueList.Add("Bachelor");
cell.Validation.ValueList.Add("Master");
cell.Validation.ValueList.Add("Doctor");


}
}

And for further reference, please check the source codes for the our featured demos espcially data validation i.e., http://www.aspose.com/demos/aspose.grid/default.htm

Thank you.