Apr 23, 2013, 4:58 AM
[CLOSED] How To Update Value of Dynamically Created Controls (With Dynamic ID's).
In my scenario one TreeNode Click (Click1) event is creating some dynamic controls like TextField, ComboBox, NumberField etc. with values in it (Fetching From Database).
And Second Direct Event(UpdateEvent) is Updating Data in it (by passing Some SQL queries.)
Problem is that i Could not update it, as i could not retain ID of the Controls on Update Event. ID becomes null when it comes in Update Region.
please Help it.....!
And Second Direct Event(UpdateEvent) is Updating Data in it (by passing Some SQL queries.)
Problem is that i Could not update it, as i could not retain ID of the Controls on Update Event. ID becomes null when it comes in Update Region.
please Help it.....!
aspx file
<ext:Panel ID="pnlOuterPropControls" runat="server" Width="620" Height="530">
<Items>
<ext:Panel ID="PnlPropControls" runat="server" Width="500" Height="530" PaddingSpec="20px 0px 0px 30px" AutoDataBind="true"
Border="false">
<Items>
</Items>
<Buttons>
<ext:Button ID="BtnUpdateProp" runat="server" Text="Update !" Width="100" OnDirectClick="BtnUpdateProp_Click"
Hidden="true">
</ext:Button>
</Buttons>
</ext:Panel>
</Items>
</ext:Panel>
code behind
public void Click1(object sender, DirectEventArgs e)
{
BtnUpdateProp.Show();
PnlPropControls.RemoveAll();
string TfNewParntHierName = e.ExtraParams["CmptMstrpk1"].ToString();
Session["sessionTfNewParntHierName"] = TfNewParntHierName;
string shrtdesc = fn.Selectsinglevalues("select accountShortDesc from tc_AccountCodes where pk_AccountCode = '" + TfNewParntHierName + "' ");
Session["shrtdesc"] = shrtdesc;
DataSet dsPg = fn.Selectdata("select * from dbo.tc_configuration where configPropCatgSub = '" + shrtdesc + "' order by configpropsrno asc");
for (int i = 0; i < dsPg.Tables[0].Rows.Count; i++)
{
string Controlpk = dsPg.Tables[0].Rows[i]["pk_configuration"].ToString();
string ControlType = dsPg.Tables[0].Rows[i]["configPropType"].ToString();
string ControlDataType = dsPg.Tables[0].Rows[i]["configPropDataType"].ToString();
string ControlItem = dsPg.Tables[0].Rows[i]["configPropItem"].ToString();
if (ControlType == "Numeric")
{
NumberField nFNumericData = new NumberField();
nFNumericData.ID = "nFNumericData_" + i.ToString();
nFNumericData.MaxValue = 100;
nFNumericData.MinValue = 0;
nFNumericData.Text = fn.Selectsinglevalues("select configPropValue from tc_configuration where pk_configuration = '" + Controlpk + "' ");
nFNumericData.FieldLabel = fn.Selectsinglevalues("select configPropItem from tc_configuration where pk_configuration = '" + Controlpk + "' ");
PnlPropControls.Items.Add(nFNumericData);
nFNumericData.Render();
}
}
}
public void BtnUpdateProp_Click(object sender, DirectEventArgs e)
{
DataSet ds = fn.Selectdata("select * from dbo.tc_configuration where configPropCatgSub = '" + Session["shrtdesc"] + "' order by configpropsrno asc");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string Controlpk = ds.Tables[0].Rows[i]["pk_configuration"].ToString();
string ControlType = ds.Tables[0].Rows[i]["configPropType"].ToString();
string ControlDataType = ds.Tables[0].Rows[i]["configPropDataType"].ToString();
string ControlItem = ds.Tables[0].Rows[i]["configPropItem"].ToString();
TextField tfDescription = (TextField)PnlPropControls.FindControl("tfDescription");
NumberField nFNumericData = (NumberField)PnlPropControls.FindControl("nFNumericData");
TextBox tbnnn = (TextBox)PnlPropControls.FindControl("tbnnn");
if (ControlType == "Numeric") // Checking condition "Values Stored in DB"
{
fn.updatedata(" update tc_configuration set configPropValue = '" + nFNumericData.Value + "' where pk_configuration = '" + Controlpk + "' ");
}
}
}
Last edited by Daniil; Apr 24, 2013 at 6:29 AM.
Reason: [CLOSED]