I am trying to fix this page in aspx 3.5 , C# . The code is in Linq and does not insert the values from the form.
I have about 20 fields to be updated in a single aspx page, whoever developed this page did the following:
divided the page into 4 sections, each section has its own edit hyperlinked button to put the section in edit mode( for all 4 sections) a user can make a selection from drop down list to filter the requested records from the DB, then once the form is populated, a user can click any edit hyperlink ( in one of the four sections above ). however, when I run it , it does not make update to the table. Here is some code . I never worked with Linq, so your help is apprecited.... why it is not making the update when I call the stored procedure.. I have used the debuger and find out that this method does not capture the values from the GUI ... private Dictionary
Most of the aspx page contains label, sever control, div tag with runat="server" (not sure why it is there??) and
tag
this is part of the code behind , it does not capture the values from the GUI ??
protected void btnSaveData_Click(object sender, EventArgs e)
{
#region No longer Used
Dictionaryvalues = GetValues();
if (values != null && values.Count > 0)
{
int? retVal = apporBL.SubmitApportionmentValues(ddlAslProgram.SelectedValue,
Convert.ToInt32(ddlCohort.SelectedValue), Convert.ToInt32(ddlFiscalYear.SelectedValue),
values);
if (retVal != null || retVal != 0)
{
//lbAssocBudgets.Items.Clear();
#region Reset Values
ResetHtmlControls();
//foreach ( TextBox t in inputControls )
//{
// t.Text = String.Empty;
//}
lblError.Visible = true;
lblError.Text = "Data successfully submitted!!!!";
#endregion
btnSubmitFilter_Click(this, new EventArgs());
}
}
#endregion
}
#region Helper Methods
///
/// Retrieve the Values from the UI
///
///Key/Value pairs for all the input controls within div.valueContainer
private DictionaryGetValues()
{
ListinputControls = (from Control c in this.Page.Form.Controls[11].Controls
where c.GetType() == typeof(TextBox)// && !String.IsNullOrEmpty( ( (TextBox)c ).Text )
select c).ToList();
ListdivControls = (from Control c in this.Page.Form.Controls[11].Controls
where c.GetType() == typeof(HtmlGenericControl) &&
((HtmlGenericControl)c).TagName == "div"
select c).ToList();
Dictionaryvalues = new Dictionary ();
if (inputControls.Count > 0)
{
int i = 0;
foreach (TextBox t in inputControls)
{
// Ignore TextBoxes that have the class "calculatedField"
if (t.CssClass != "calculatedField")
{
// Stores the new Value in to the Array
if (!String.IsNullOrEmpty(t.Text))
{
values.Add(t.ID, t.Text);
}
else
{
// Takes the Old value and stores it into the Array
values.Add(t.ID, ((HtmlGenericControl)divControls[i]).InnerText);
}
}
else
{
// Although we ignore, we still need to pass
// a KVP to the Business Layer
values.Add(t.ID, String.Empty);
}
i++;
}
}
return values;
}
Replies
Know the answer? Post it — somebody with the same question will find it here.