1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
private void LoadChildColumns(String panelID)
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
ReorderList roList = new ReorderList();
roList.PostBackOnReorder = false;
roList.CallbackCssStyle = "callbackStyle";
roList.AllowReorder = true;
roList.DragHandleAlignment = ReorderHandleAlignment.Left;
roList.DataKeyField = "SLPropertyColumnID";
roList.SortOrderField = "DataIndex";
roList.DataSource = GetDataSourceForROList(panelID);
roList.ItemInsertLocation = ReorderListInsertLocation.Beginning;
roList.ItemTemplate = new CustomItemTemplate(roList);
roList.DragHandleTemplate = new CustomDragHandleTemplate(roList);
roList.ReorderTemplate = new CustomReorderTemplate(roList);
td.Controls.Add(roList);
GridView gv = new GridView();
gv.GridLines = GridLines.None;
gv.Enabled = true;
gv.AutoGenerateColumns = false;
gv.DataSource = GetDataSourceForROList(panelID);
TemplateField tField = new TemplateField();
tField.ItemTemplate = new CustomGridItemTemplate(gv);
DataControlField tCol = tField;
gv.Columns.Add(tCol);
BoundField field = new BoundField();
field.DataField = "TextLabel";
field.HeaderText = "Prompt";
DataControlField Col = field;
gv.Columns.Add(Col);
CheckBoxField cfield = new CheckBoxField();
cfield.DataField = "Visibility";
cfield.HeaderText = "Should Appear";
DataControlField Col1 = cfield;
gv.Columns.Add(Col1);
td.Controls.Add(gv);
gv.DataBind();
tr.Cells.Add(td);
dtProperty.Rows.Add(tr);
roList.DataBind();
}
private SqlDataSource GetDataSourceForROList(String PanelID)
{
SqlDataSource sdc = new SqlDataSource();
sdc.ConnectionString = ConString;
sdc.SelectCommand = " Select p.SLPropertyColumnID, p.TextLabel, c.Visibility, c.DataIndex" +
" FROM SLPropertyClientConfiguration c" +
" LEFT OUTER JOIN SLPropertyColumnConfiguration p ON c.SLPropertyColumnID = p.SLPropertyColumnID" +
" WHERE c.ClientID = " + ClientID.ToString() + " AND p.SLPanelID = " + PanelID +
" ORDER BY c.DataIndex, p.TextLabel";
//The SELECT and UPDATE methods should have the same number of fields !!!!!!!
sdc.UpdateCommand = " UPDATE SLPropertyColumnConfiguration" +
" SET DataIndex = @DataIndex" +
" WHERE SLPropertyColumnID = @original_SLPropertyColumnID";
sdc.OldValuesParameterFormatString = "original_{0}";
sdc.ProviderName = "System.Data.SqlClient";
sdc.UpdateParameters.Add(new Parameter("@DataIndex", DbType.Int32));
sdc.UpdateParameters.Add(new Parameter("@original_SLPropertyColumnID", DbType.Int32));
return sdc;
} |
Partager