hi
in sendmessage.aspx is 2 Linkbutton and 1 textbox and 2 gridview
1-LBaddNumber
2-LBAddPhone
3-Txtphone
4-Lblcount
these are linkbuttons code:
protected void LBaddNumber_Click(object sender, EventArgs e)
{
ViewUsersInfo();
string numbers = string.Empty;
foreach (GridViewRow row in GridView1.Rows)
{
numbers += (row.FindControl("LblNumber") as Label).Text.Trim() + Environment.NewLine;
}
TxtPhone.Text = numbers.Trim();
CountMessage();
}
protected void LBAddPhone_Click(object sender, EventArgs e)
{
GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
string number = (row.FindControl("Lblmobile") as Label).Text.Trim();
TxtPhone.Text = number.Trim() + Environment.NewLine + TxtPhone.Text;
Lblcount.Text = (TxtPhone.Text.Split('\r').Length - 1).ToString();
}
private void CountMessage()
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("CountPhone", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@group1", DDlSgroupF.SelectedItem.Text);
cmd.Parameters.AddWithValue("@group2", DDlSgroupS.SelectedItem.Text.Trim());
conn.Open();
SqlDataReader _dr = cmd.ExecuteReader();
while (_dr.Read())
{
Lblcount.Text = toPersianNumber(_dr["Phone"].ToString());
}
}
}
}
here when click on Lbaddnumber it will put gridview1 Lblnumber into textbox (all number) and will display count of number in Lblcount(see countmessage metod)
and when click on LBaddphone it will put gridview2 Lblmobile in Txtphone(just number from selected row) and will display count of number into Lblcount...
Lblcount.Text = (TxtPhone.Text.Split('\r').Length - 1).ToString();
now here when I click on Lbladdnumber it will put number from gridview1 into Txtphone for example in gridview1 are 3 number it will put all 3 number into Txtphone like:
11111111
2222222
3333333
and Lblcount :3
now I click on Lbaddphone to add 1 number from gridview2 into Txtphone (like 444444) so it will be:
444444 ------->selected number from gridview2
111111
222222
333333
but here Lblcount again display:3 here I expect that it shows Lblcount:4 but it doesn't
again I select other number from gridview2 (like 55555 ) it will be:
555555 ------->selected number from gridview2
444444 ------->selected number from gridview2
111111
222222
333333
and in LblCount :4
I mean in Lblcount will display 1 number less...
it happen when at first I put number from gridview1(Lbaddnumber) and then put number from gridview2(Lbaddphone)...
what shoud I do?
Best Regards
neda