Click here to Skip to main content
15,896,154 members

Comments by Pallavi Waikar (Top 115 by date)

Pallavi Waikar 19-Jul-13 3:24am View    
for that u have to use two update panel one for autocomplete textbox and secound for grid panel and in _dopostback give name of secound update panel<br/>.I have also used one trick of secound textbox that will use to fill gridview
example:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<contenttemplate>
<asp:TextBox ID="TextBox1" onkeyup="AssignValues();" runat="server" >
<ajax:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="TextBox1"
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" ServiceMethod="GetEmployees" >



<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
<contenttemplate>
<asp:GridView ID="GridView1" runat="server">


<br />
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="TextBox2_TextChanged" style="display:none" AutoPostBack="True" >
<asp:HiddenField ID="HiddenField1" runat="server"
onvaluechanged="HiddenField1_ValueChanged" />

</div>
<script type="text/javascript">
function AssignValues() {
document.getElementById("TextBox2").value=document.getElementById("TextBox1").value;
PanalRefrshOnTextChange();

}
</script>
<script type="text/javascript">
function PanalRefrshOnTextChange() {

__doPostBack('<%= UpdatePanel2.ClientID %>', '');
};

//Code file use textbox2 textchange event
protected void TextBox2_TextChanged(object sender, EventArgs e)
{

string cn=ConfigurationManager.ConnectionStrings["testing"].ConnectionString;
using(SqlConnection connection = new SqlConnection(cn))
{


SqlCommand command = new SqlCommand("select * from country where EmployeeName like(@EmployeeName)", connection);
command.Parameters.AddWithValue("@EmployeeName", TextBox1.Text.Trim()+"%");
connection.Open();
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
connection.Close();
}
Pallavi Waikar 18-Jul-13 9:31am View    
it simple check text box is blank or not it not then do above code or in else bind it to null
example:
if (TextBox1.Text.Trim() != "")
{
//oyur bind code
}
else
{
GridView1.DataSource = null;
GridView1.DataBind();
}

Pallavi Waikar 18-Jul-13 6:44am View    
also use like in select query as i have used. it fill as value entered in textbox
Pallavi Waikar 18-Jul-13 6:42am View    
for that you have to use ajax update panel and trigger check update answer..check updated anser and try to implement in your code.
Pallavi Waikar 15-Jul-13 8:28am View    
I want to tell you this is also one way show confirmation box,i know this article is not for your question but can help u to show second confirm.you can also give one checkbox backup my data.In coding check for it and proceed as per value.