PDA

View Full Version : [CLOSED] Controls not updating from Direct Event



hidaextnet
Sep 02, 2013, 6:04 AM
Hi,

In a web from, I'm updating some controls (labels , textbox etc) on Direct Event called on combo select event but its not updating the controls.
Could you please suggest me why its not updating ??
Thanks ,

geoffrey.mcgill
Sep 02, 2013, 6:30 AM
Hello,

Please see #1 at the following location,

http://forums.ext.net/showthread.php?10205-More-Information-Required

hidaextnet
Sep 02, 2013, 6:55 AM
Here is the code


<ext:ComboBox ID="cmbLoanNo" runat="server" MatchFieldWidth="False" PageSize="10"
TypeAhead="True" DisplayField="LOAN_NO" ValueField="LOAN_NO" RTL="True" IDMode="Explicit"
IsDynamic="False" Namespace="App" RenderXType="True">
<Store>
<ext:Store runat="server" ID="dsLoan" OnReadData="dsLoan_ReadData" PageSize="10"
ClearOnPageLoad="False">
<Proxy>
<ext:PageProxy>
</ext:PageProxy>
</Proxy>
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="LOAN_NO">
<Fields>
<ext:ModelField Name="LOAN_NO" ServerMapping="LOAN_NO" />
<ext:ModelField Name="LOAN_DESC" ServerMapping="LOAN_DESC" />
<ext:ModelField Name="LOAN_AMT" ServerMapping="LOAN_AMT" />
<ext:ModelField Name="LOAN_DATE" ServerMapping="LOAN_DATE" />
</Fields>
</ext:Model>
</Model>
<Listeners>
</Listeners>
</ext:Store>
</Store>
<DirectEvents AutoDataBind="True">
<Select OnEvent="cmbLoanNo_ValueChanged">
</Select>
</DirectEvents>
<ListConfig Width="260" Height="300" ItemSelector=".x-boundlist-item">
<Tpl ID="Tpl2" runat="server">
<Html>
<tpl for=".">
<tpl if="[xindex] == 1">
<table class="cbStates-list">
<tr>
<th>رقم القروض</th>
<th>وصف قرض</th>
<th>كمية</th>
<th>تاريخ</th>
</tr>
</tpl>
<tr class="x-boundlist-item">
<td>{LOAN_NO}</td>
<td>{LOAN_DESC}</td>
<td>{LOAN_AMT}</td>
<td>{LOAN_DATE}</td>
</tr>
<tpl if="[xcount-xindex]==0">
</table>
</tpl> </tpl> </Html> </Tpl> </ListConfig> </ext:ComboBox>


Code Behind


[DirectMethod]
public void cmbLoanNo_ValueChanged(object sender, DirectEventArgs e)
{
if (cmbLoanNo.SelectedItem.Value != null)
{
DataTable dt = (DataTable)ViewState["LoanPlan"];

DataTable dt2 = new DataTable();
dt2 = dt.Copy();
DataTable dtrt = GetLoanNoDetails(dt, cmbLoanNo.SelectedItem.Value == null ? "" : cmbLoanNo.SelectedItem.Value.ToString());

ViewState["LoanPlan"] = dt2;
if (dtrt.Rows.Count > 0)
{
LoanDate.Text = dtrt.Rows[0]["LOAN_DATE"].ToString();
if (dtrt.Rows[0]["CALC_TYPE"].ToString().ToUpper() == "FIXED")
{
InstallmentType.Text = "ثابت";
}
else
{
InstallmentType.Text = "عدد القسط";
}
EmpName2.Text = dtrt.Rows[0]["EMPLOYEE_NAME"].ToString();
LoanCode.Text = dtrt.Rows[0]["LOAN_TYPE"].ToString();
LoanAmt.Text = dtrt.Rows[0]["LOAN_AMT"].ToString();
InstValue.Text = dtrt.Rows[0]["INSTALL_VALUE"].ToString();
Position.Text = dtrt.Rows[0]["POSITION"].ToString();
LoanDesc2.Text = dtrt.Rows[0]["LOAN_DESC"].ToString();
RecovDate.Text = dtrt.Rows[0]["RECOV_ST_DATE"].ToString();
}
grvLoanplanDetails.DataSource = dtrt;
grvLoanplanDetails.DataBind();
}


}

Daniil
Sep 02, 2013, 12:17 PM
Hi @hidaextnet,

So, are the controls that you mean - LoanDate, EmpName2, etc.?

What are those controls? Is it Ext.NET controls? I cannot see them in the code snippet.

Did you check (debug) these code lines are actually executed?

LoanDate.Text = dtrt.Rows[0]["LOAN_DATE"].ToString();

EmpName2.Text = dtrt.Rows[0]["EMPLOYEE_NAME"].ToString();
etc.

By the way, you don't need a [DirectMethod] attribute for a DirectEvent handler.

hidaextnet
Sep 02, 2013, 12:48 PM
Hi @hidaextnet,

So, are the controls that you mean - LoanDate, EmpName2, etc.?

What are those controls? Is it Ext.NET controls? I cannot see them in the code snippet.

These are asp controls



Did you check (debug) these code lines are actually executed?

LoanDate.Text = dtrt.Rows[0]["LOAN_DATE"].ToString();

EmpName2.Text = dtrt.Rows[0]["EMPLOYEE_NAME"].ToString();
etc.

By the way, you don't need a [DirectMethod] attribute for a DirectEvent handler.

I've checked , these lines are executing.

Daniil
Sep 02, 2013, 1:01 PM
To get an ASP.NET control updated during a DirectEvent/DirectMethod you have to call its Update method.

LoanDate.Text = dtrt.Rows[0]["LOAN_DATE"].ToString();
LoanDate.Update();