Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
create dynamic dropdown in grid
posted

HI i just want to create dynamic drop down control in only some rows depend on the condition.

how to create that drop down control in this.

here i have written some code.

here need note down that other values in colums shold not be update (means fixed) and

can i use templated colmun in that column1 caz some of the values are fixed only some are with droup down control.

menas in cloumn1

row1column1 == fixed value

row2column1 == fixed value

row3column1 == templated dropdownlist.

row4cloumn1 == nothing that is null or empty string

row5column1 == fixed value

row6column1 == templated dopdownlist.

and so on.

here i have tried to write down some code.

if (condition)

{

DropDownList drpMonthGrid = new DropDownList();

drpMonthGrid.DataSource = CC.dtMonthList(); // I have create datatable to display each item in the droup down list.

// Specify DisplayMember as "Year" field of datatable

drpMonthGrid.ID = e.Row.Index + "Month";drpMonthGrid.DataValueField = "Month";

drpMonthGrid.DataBind();

drpMonthGrid.SelectedValue =
DateTime.Now.Month.ToString();

 

this.uwgList.Bands[0].Columns.FromKey("Column2").Type = new ColumnType();/*ValueList drpMonthGrid = this.uwgList.Bands[0].Columns.FromKey("Column2").ValueList;

drpMonthGrid.DataSource = CC.dtMonthList();

// Specify DisplayMember as "Year" field of datatable

drpMonthGrid.DataSourceID = "Month";

drpMonthGrid.DisplayMember = "Month";

drpMonthGrid.DataBind();

*/

//drpMonthGrid.SelectedValue = DateTime.Now.Month.ToString();

/*TemplatedColumn tcValue = (TemplatedColumn)e.Row.Cells.FromKey("Column2").Column;

CellItem ciValue = (CellItem)tcValue.CellItems[e.Row.Index];

//ciValue.Controls.Add(drpMonthGrid);

*/

e.Row.Cells.FromKey("Column1").Text = "<a href='Report1.aspx?ClientName=" + e.Row.Cells.FromKey("type").Value + "' target='_blank'>Remove</a>";

// here in below i just want to add that drop down control in the terms Column2.

e.Row.Cells.FromKey("Column2").Text = "";

 

}

please let  me know the correct code.