Help on Search Button

Posted by Vijayar under C# on 6/28/2011 | Points: 10 | Views : 2908 | Status : [Member] | Replies : 3
Hi
I had a textbox by name txtsearch ,by the side of it i placed a image which displays a calendar ,on clicking on it,date will be placed in textsearch,i Can select,today,1 week before,1 month by clicking on this image.where to write the code to search a record .i have written a code in text-changed event but not getting fired.Please help me

vijaya


Responses

Posted by: Ndebata on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
Try to use calendar extender for this
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Calendar/Calendar.aspx

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
you can do that first select date using calendar control before that put autopostback=true for textbox and then write code in textbox textchanged
event

secondway put one button and write it in button1 click event

Thanks&Regards
LakshmiNarayana Nalluri.

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayar on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
HI
<tr>
<td>
<asp:Label ID="lblsearch" runat="server" Text="Search" Width="80px"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtsearch" runat="server" CssClass="txtbox" OnTextChanged="txtsearch_TextChanged" AutoPostBack="true"></asp:TextBox>
</td>
<td>
<asp:ImageButton ID="btnsearch" runat="server" ImageUrl="~/images/gnome-searchtool.png"
Width="25px" Height="25px" />
</td>
</tr>
Here btnserach acts like a calendar control(so that i can select,today,after 1 week,before day....) options.after selecting the day i need to search for the record based on the selection,i wrote a code in txtsearch_textchanged event,but not getting fired.how to do write and in which event i should write code


protected void txtsearch_TextChanged(object sender, EventArgs e)
{


try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings[""].ToString();
conn.Open();

SqlDataAdapter da = new SqlDataAdapter("SELECT distinct ApplicantID,DataSourceId,ApplicantName,r.ContactNumber,AlternateContactNumber,r.Gender,EmailId, CountryIntersted,OtherCountryName,r.EmployeeId, FollowUpId,BranchId,AppointmentDate,AppointmentTime,Comments,r.Description,r.EntryBY,r.CreatedDate,r.ModifiedDate, e.FirstName +' '+e.LastName as EntryName FROM RCNewApplicants r,EmployeePersonalDetails e where r.EntryBY=e.EmployeeId and r.CreatedDate=" + txtsearch.Text, conn);

DataSet ds = new DataSet();
da.Fill(ds);

gvnotassigned.DataSource = ds;
gvnotassigned.DataBind();


}
catch (Exception ex)
{

ex.Message.ToString();
}
}

vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response