hi
there is textbox(TxtPhone) and gridview and lable(LblTshE) in page
below is gridview's code:
protected void LBaddNumberG_Click(object sender, EventArgs e)
{
GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
string number = (row.FindControl("Lblmobile") as Label).Text.Trim();
if (!string.IsNullOrEmpty(TxtPhone.Text))
{
TxtPhone.Text = number.Trim() + Environment.NewLine + TxtPhone.Text;
}
else
{
TxtPhone.Text = number.Trim();
}
LblTshE.Text = (TxtPhone.Text.Split('\r').Length).ToString();
LblTph.Text = toPersianNumber((TxtPhone.Text.Split('\r').Length).ToString());
if ((LbltedaP.Text) != "")
{
Lblsum.Text = Convert.ToInt32((Convert.ToDouble(LblTshE.Text) * Convert.ToDouble(LbltedaP.Text))).ToString();
}
}
in gridview is linkbutton that when click on it will add number to txtphone and will add count of numbers in LblTshE like:
033213
032165
Count of number:2
and below is java code fo txtphone..
<script type="text/javascript">
$(function () {
var value = '';
$('[Id*=TxtPhone]').keypress(function (e) {
if (e.which == 13) {
var temp = $(this).val();
value = temp + "@" + value;
var count = value.split('@').length - 1;
$('[Id*=LblTshE]').html(count);
$('[id*=Lblsum]').html(($('[Id*=LbltedaP]').html()) * ($('[Id*=LblTshE]').html()));
}
});
});
</script>
here in above code if users type number into textbox it will display count of number in LblTshE...
so when users click on linkbutton from gridview to add number or type number directly into textbox it will display Count of number in lblTshE...
now problem is that when I select number from gridview like below:
01223354
01354545
0133555
count of number:3
it will display 3 in LblTshE it is correct but after that when I add new number in textbox directly(don't select from gridview type directly) it will be like:
01223354 --------->add from grid view
01354545 --------->add from grid view
0133555 --------->add from grid view
1111111 ---------->typed into textbox
count of number:1
it will display :1 in LblTshE...
why this happen it should display:4
best regards
neda