protected void hfEditorData_Init(object sender, EventArgs e) { ASPxHiddenField hiddenField = sender as ASPxHiddenField; GridViewEditFormTemplateContainer container = hiddenField.NamingContainer as GridViewEditFormTemplateContainer; foreach (GridViewColumn col in container.Grid.Columns) { GridViewDataColumn dataCol = col as GridViewDataColumn; if ((dataCol != null) && (!hiddenField.Contains(dataCol.FieldName))) { hiddenField[dataCol.FieldName] = DataBinder.Eval(container.DataItem, dataCol.FieldName); } } }
void cellEditor_Init(object sender, EventArgs e) { ASPxEdit editor = sender as ASPxEdit; GridViewDataItemTemplateContainer container = editor.NamingContainer as GridViewDataItemTemplateContainer; editor.Width = new Unit(100, UnitType.Percentage); ASPxHiddenField hfData = container.Grid.FindTitleTemplateControl("hfData") as ASPxHiddenField; string fieldKey = String.Format("{0}_{1}", container.KeyValue, container.Column.FieldName); editor.Value = (hfData != null && hfData.Contains(fieldKey)) ? hfData[fieldKey] : DataBinder.Eval(container.DataItem, container.Column.FieldName); editor.SetClientSideEventHandler("ValueChanged", String.Format("function(s, e) {{ {0}_hfData.Set('{1}', s.GetValue()); }}", container.Grid.UniqueID, fieldKey)); }
protected void Page_Load(object sender, EventArgs e) { pageScore.Visible = false; if (ItemKey == null || SelectedScorecard == null) { pageScore.Visible = false; return; } else if (!rootParameters.Contains("ScorecardNeedsSave")) { pageScore.Visible = true; PrepareScorecard(SelectedScorecard, ItemKey, false); //Save Session values for refresh Session["card_id"] = SelectedScorecard; Session["score_itemid"] = ItemKey; //SelectedScorecard = e.Parameter; } //BindForm(); }
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { ASPxGridView gridView = sender as ASPxGridView; ASPxHiddenField hfData = gridView.FindTitleTemplateControl("hfData") as ASPxHiddenField; OleDbConnection connection = GetConnection(); if (connection == null) { return; } for (int i = 0; i < gridView.VisibleRowCount; i++) { bool isRowUpdated = false; object[] values = new object[gridView.Columns.Count]; foreach (GridViewDataColumn column in gridView.Columns) { string fieldKey = String.Format("{0}_{1}", gridView.GetRowValues(i, gridView.KeyFieldName), column.FieldName); if (hfData.Contains(fieldKey)) { values[column.Index] = hfData[fieldKey]; isRowUpdated = true; } else { values[column.Index] = gridView.GetRowValues(i, column.FieldName); } } if (isRowUpdated) { UpdateGrid(connection, gridView, values); } } connection.Close(); gridView.DataBind(); }
public void BindForm() { //bind the dropdown if (AllowAssessment == true) { dropAssessment.DataSource = common_services.GetCustomDropDown("response"); dropAssessment.DataBind(); } //First check to see if MIlestones are allowed/needed in the first place, if not, just set it null //If widget is set to static milestones, hide dropdown and set MIlestoneID property based on rootParameter given by Root.Master. // If the parameter is not given, then this is a page that does not require milestones //If it is fluid, then make the dropdown visible, select the last value selected if available, and set MIlestoneID=dro if (AllowMilestone == true) { if (StaticMilestone == true) { dropMilestone.Visible = false; if (Session["MilestoneID"] != null) { MilestoneID = Session["MilestoneID"].ToString(); } //else // If it hasn't been set, it means this page does not use MIlestones - set null //{ // MilestoneID = null; //} } else { dropMilestone.DataSource = common_services.GetFluidMilestones(); dropMilestone.DataBind(); dropMilestone.Visible = true; if (rootParameters.Contains("SelectedMilestone")) { try { dropMilestone.SelectedIndex = Convert.ToInt32(rootParameters["SelectedMilestone"]); MilestoneID = (string)dropMilestone.SelectedItem.Value; } catch { } } else { //at this point we know the page needs a milestone, and it is fluid, yet there is no value. // this means the user has not picked one yet, so we just pick the first milestone because // the Stored Procedure inserts if it select returns null, and we don't want to insert with MIlestoneID=null if MIlestone is required.. try { MilestoneID = (string)dropMilestone.Items[0].Value; } catch { } } } } else { MilestoneID = null; } //Now bind that response based on milestone AssessmentResponse Response = new AssessmentResponse(); // Response = rc_services.GetResponse(Guid.Parse(ItemKey), MilestoneID); txResponse.Html = Response.Response; dropAssessment.Value = Response.Assesment; AssessmentValue = Response.Assesment; ResponseID = Response.ResponseID.ToString(); dropMilestone.SelectedItem = dropMilestone.Items.FindByValue(MilestoneID); dropAssessment.SelectedItem = dropAssessment.Items.FindByValue(Response.Assesment); }