hello ,
I am using search by ajax Toolkit AutoCompleteExtender.
HTML
<asp:TextBox ID="txtSearch" runat="server" AutoPostBack="True" BackColor="#FFFFCC" Font-Bold="True" Font-Names="Arial" Font-Size="X-Large" Height="30px" OnTextChanged="txtSearch_TextChanged" placeholder="الاسم / رقم المدنى" Style="text-align: center" Width="300px"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionInterval="100" CompletionSetCount="10" EnableCaching="false" FirstRowSelected="false" MinimumPrefixLength="2" ServiceMethod="SearchCustomers" TargetControlID="txtSearch">
</ajaxToolkit:AutoCompleteExtender>
<asp:Button ID="Button33" runat="server" OnClick="Search" CssClass="btn3" Font-Bold="True" Font-Names="Arial" Height="35px" Width="50px" Font-Size="Large" BorderStyle="None" BackColor="#20519D" ForeColor="White" Text="بحث" />
the search work perfect
i have 10 Group's like GroupA , GroupB , GroupC .... if anyone trying search its dispaly all users groups
i want if user from groupC search users, i want only dispaly/show users from groupC
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();
Adminset.Text = rdr["RoleId2"].ToString();
ddlCountries.SelectedItem.Text = rdr["Countries"].ToString();
ddlStates.SelectedItem.Text = rdr["States"].ToString();
ddlCities.SelectedItem.Text = rdr["Cities"].ToString();
toplist.Text = rdr["CountryId3"].ToString();
Passwordupdate.Text = rdr["password"].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 = " ";
Adminset.Text = " ";
ClientScript.RegisterClientScriptBlock(GetType(), "alert",
"alert('" + "لاتوجد بيانات\\n " + txtSearch.Text.ToString() + "');", true);
}
sqlcon.Close();
}
catch (Exception)
{
}
}
StoredProcedure
USE [cm]
GO
/****** Object: StoredProcedure [dbo].[Insert_Userupdate] Script Date: 29/03/2023 03:35:49 م ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Insert_Userupdate]
(
@name nvarchar(max),
@civilid nvarchar(max)
)
as
begin
Select * from Table_infoname where name LIKE '%' + @name +'%' OR civilid LIKE '%' + @civilid +'%'
end