hello,
Its wrong code clear after search other user, when i search for first user i got all info.
Then when i try search other user without full info like from DropDownList not add country, i get same country first user search before
protected void Searchdata()
{
try
{ String constring = ConfigurationManager.ConnectionStrings["cmConnectionString"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(constring);
String pname = "Insert_Userupdate";
sqlcon.Open();
SqlCommand com = new SqlCommand(pname, sqlcon);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("civilid", txtSearch.Text);
com.Parameters.AddWithValue("name", txtSearch.Text);
SqlDataReader rdr;
rdr = com.ExecuteReader();
if (rdr.Read())
{
fName.Text = rdr["name"].ToString();
ffileid.Text = rdr["fileid"].ToString();
fcivilid.Text = rdr["civilid"].ToString();
codeid.Text = rdr["id"].ToString();
mobile.Text = rdr["mobile"].ToString();
joptitel.Text = rdr["jop"].ToString();
ddlCountries2.Text = rdr["Countries"].ToString();
ddlStates2.Text = rdr["States"].ToString();
ddlCities2.Text = rdr["Cities"].ToString();
toplist.Text = rdr["CountryId3"].ToString();
if (fcivilid.Text.Trim().Length == 12)
{
int year = 0;
if (fcivilid.Text.StartsWith("3"))
{
year = Convert.ToInt32("20" + fcivilid.Text.Substring(1, 2));
}
else if (fcivilid.Text.StartsWith("2"))
{
year = Convert.ToInt32("19" + fcivilid.Text.Substring(1, 2));
}
int current = DateTime.Today.Year;
result_civilid_Age.Text = (current - year).ToString();
}
}
else
{
fName.Text = " ";
fcivilid.Text = " ";
ffileid.Text = " ";
codeid.Text = " ";
toplist.Text = " ";
result_civilid_Age.Text = " ";
ddlCountries.Items.Clear();
ddlStates.Items.Clear();
ddlCities.Items.Clear();
ddlStates.Items.Insert(0, new ListItem("إسم الإدارة", "0"));
ddlCities.Items.Insert(0, new ListItem("إسم القسم", "0"));
ddlCountries.Items.Insert(0, new ListItem("إسم القطاع", "0"));
ClientScript.RegisterClientScriptBlock(GetType(), "alert",
"alert('" + "لاتوجد بيانات\\n " + txtSearch.Text.ToString() + "');", true);
}
sqlcon.Close();
}
catch (Exception)
{
}
}
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<table align="center" border="2" class="auto-style13" dir="rtl">
<tr>
<td class="auto-style224">
<fieldset class="auto-style9">
<asp:TextBox ID="txtSearch" Style="text-align: center" placeholder="الاسم / رقم المدنى" runat="server" AutoPostBack="True" BackColor="#FFFFCC" Font-Names="Arial" Font-Size="X-Large" OnTextChanged="txtSearch_TextChanged" Width="300px" Height="31px" Font-Bold="True"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServiceMethod="SearchCustomers"
MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtSearch" FirstRowSelected="false">
</ajaxToolkit:AutoCompleteExtender>
<br />
<asp:Button ID="Button30" runat="server" Text="بحث" OnClick="btnsavedata" CssClass="button" Font-Bold="True" Font-Names="Arial" Height="35px" Width="50px" Font-Size="12pt" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" />
<asp:Button ID="ButNewuser" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="12pt"
OnClick="NewUser" Text="جديد" CssClass="button" Height="35px" Width="50px" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" />
<asp:Button ID="Button25" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="12pt"
OnClick="RegisterUser" Text="حفظ" CssClass="button" Height="35px" Width="50px" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" />
</fieldset>
</table>
<table align="center" style="border: thin solid #000000; font-family: Arial, Helvetica, sans-serif; height: 40px;">
<tr>
<td class="auto-style34" style="border: medium solid #000000" colspan="3">
<asp:Label ID="Label11" runat="server" Font-Size="Large" ForeColor="White" Text="بيانات الموظف" Font-Bold="True" Font-Names="Arial"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style17" style="border: thin solid #000000;">
<asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Black" Text="الإسم" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style54">
<asp:TextBox ID="fName" runat="server" Font-Size="Medium" ForeColor="Black" BorderStyle="None" Font-Names="Arial" Height="100%" Font-Bold="True"></asp:TextBox>
</td>
<td style="border: thin solid #000000;" class="auto-style43">
<asp:Label ID="codeid" runat="server" Font-Size="Large" ForeColor="Gray" Height="100%" Text="0" Width="30%"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style45" style="border: thin solid #000000;">
<asp:Label ID="Label3" runat="server" Font-Size="Large" ForeColor="Black" Text="الرقم المدني" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style54">
<asp:TextBox ID="fcivilid" runat="server" Font-Size="Medium" ForeColor="Black" BorderStyle="None" Font-Names="Arial" Height="100%" Font-Bold="True"></asp:TextBox>
</td>
<td style="border: thin solid #000000;" class="auto-style36">
<asp:Label ID="result_civilid_Age" runat="server" Font-Size="Large" ForeColor="Red" Text="0"></asp:Label>
<asp:Label ID="result_civilid_Age0" runat="server" Font-Size="Large" ForeColor="Black" Text="سنة"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style45" style="border: thin solid #000000;">
<asp:Label ID="Label4" runat="server" Font-Size="Large" ForeColor="Black" Text="رقم الملف" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style54">
<asp:TextBox ID="ffileid" runat="server" Font-Size="Medium" ForeColor="Black" BorderStyle="None" Font-Names="Arial" Height="100%" Font-Bold="True"></asp:TextBox>
</td>
<td style="border: thin solid #000000;" class="auto-style43"> </td>
</tr>
<tr>
<td class="auto-style45" style="border: thin solid #000000;">
<asp:Label ID="Label10" runat="server" Font-Size="Large" ForeColor="Black" Text="الوظيفة" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style54">
<asp:TextBox ID="joptitel" runat="server" Font-Size="Medium" ForeColor="Black" BorderStyle="None" Font-Names="Arial" Height="100%" Font-Bold="True"></asp:TextBox>
</td>
<td style="border: thin solid #000000;" class="auto-style43">
<asp:DropDownList ID="toplist" runat="server" BackColor="#FFFF99" Font-Bold="True" Font-Size="Medium" Height="100%" Width="100%" Font-Names="Arial">
<asp:ListItem Value="top1">وزير</asp:ListItem>
<asp:ListItem Value="top2">وكيل</asp:ListItem>
<asp:ListItem Value="top3">وكيل مساعد</asp:ListItem>
<asp:ListItem Value="top4">مدير</asp:ListItem>
<asp:ListItem Value="top5">مراقب</asp:ListItem>
<asp:ListItem Value="top6">رئيس قسم</asp:ListItem>
<asp:ListItem Selected="True" Value="top7">موظف</asp:ListItem>
<asp:ListItem Value="top8">مراسل</asp:ListItem>
<asp:ListItem Value="top9">سائق</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style45" style="border: thin solid #000000;">
<asp:Label ID="Label8" runat="server" Font-Size="Large" ForeColor="Black" Text="رقم الهاتف" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style54">
<asp:TextBox ID="mobile" runat="server" BorderStyle="None" Font-Bold="True" Font-Size="Medium" Font-Names="Arial" Height="100%">0</asp:TextBox>
</td>
<td style="border: thin solid #000000;" class="auto-style50">
<asp:Button ID="Button48" runat="server" BackColor="#00CC00" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" ForeColor="Black" OnClick="Button48_Click" Text="WhatsApp" Width="100px" Height="25px" Font-Names="Arial" Font-Size="Small" />
</td>
</tr>
<tr>
<td class="auto-style25" style="border: thin solid #000000;" colspan="3">
<asp:Label ID="Label12" runat="server" Font-Size="Large" ForeColor="White" Text="الجهة" Font-Bold="True" Font-Names="Arial"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style56" style="border: thin solid #000000;">
<asp:Label ID="Label5" runat="server" Font-Size="Large" ForeColor="Black" Text="القطاع" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style57">
<cc1:ComboBox ID="ddlCountries2" runat="server" AutoCompleteMode="SuggestAppend" DataSourceID="SqlDataSource1" DataTextField="CountryName" DataValueField="CountryId" AppendDataBoundItems="False" BorderStyle="None">
</cc1:ComboBox>
</td>
<td style="border: thin solid #000000;" class="auto-style61"></td>
</tr>
<tr>
<td class="auto-style56" style="border: thin solid #000000;">
<asp:Label ID="Label6" runat="server" Font-Size="Large" ForeColor="Black" Text="الإدارة" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style57">
<cc1:ComboBox ID="ddlStates2" runat="server" AutoCompleteMode="SuggestAppend" DataSourceID="SqlDataSource2" DataTextField="StateName" DataValueField="StateName" MaxLength="0" BorderStyle="None" Font-Size="Medium" ForeColor="Blue" Font-Names="Arial">
</cc1:ComboBox>
</td>
<td style="border: thin solid #000000;" class="auto-style58">
<asp:Button ID="ButtonLocations0" runat="server" BackColor="#FF9933" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Names="Arial" Font-Size="Large" ForeColor="Black" Text="اضافة إدارة" Width="100px" OnClick="ButtonLocations0_Click" Height="25px" />
</td>
</tr>
<tr>
<td class="auto-style56" style="border: thin solid #000000;">
<asp:Label ID="Label7" runat="server" Font-Size="Large" ForeColor="Black" Text="القسم" Font-Bold="True" Font-Names="Arial" CssClass="auto-style62"></asp:Label>
</td>
<td style="border: thin solid #000000;" class="auto-style57">
<cc1:ComboBox ID="ddlCities2" runat="server" AutoCompleteMode="SuggestAppend" DataSourceID="SqlDataSource3" DataTextField="CityName" DataValueField="CityName" MaxLength="0" BorderStyle="None" Font-Size="Medium" Font-Names="Arial">
</cc1:ComboBox>
</td>
<td style="border: thin solid #000000;" class="auto-style58">
<asp:Button ID="ButtonCities" runat="server" BackColor="#FF9933" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Names="Arial" Font-Size="Large" ForeColor="Black" Text="اضافة قسم" Width="100px" OnClick="ButtonCities_Click" Height="25px" />
</td>
</tr>
<tr>
<td style="border: medium solid #000000" colspan="3" class="auto-style49">
<asp:Button ID="Button28" runat="server" BorderColor="Black" BorderStyle="None" BorderWidth="1px" OnClick="Button28_Click" Text="تحـــــديث" BackColor="#99CCFF" Font-Bold="True" Font-Names="Arial" Font-Size="Large" Width="100%" />
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:cmConnectionString %>" SelectCommand="SELECT * FROM [Cities]" />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:cmConnectionString %>" SelectCommand="SELECT * FROM [States]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cmConnectionString %>" SelectCommand="SELECT * FROM [Countries]"></asp:SqlDataSource>
</div>
</asp:Content>