I Have a jQuery dialog with 4 Textbox and a Search Button. I want to search a value from my database then display that value in GridView each textbox has a string @firstname
@lastname
@address
@mobile
user may put a value in any of the textbox and if they click the btnSearch_Click
value will display in a GridView.
I hope you understand my problem(not good at english and new in programming).
Problem: If user enter a value in any of the textbox value will display in gridview and dialog should close
js:
<script type="text/javascript">
$(function () {
$("#Searchprod").dialog({
appendTo: "form",
autoOpen: false,
width: 630,
height: 350,
draggable: false,
resizable: false,
modal: true
});
$("#btnupregSearch").click(function () {
$("#Searchprod").dialog("open");
return false;
});
});
</script>
dialog w/ textbox and button:
<div id="Searchprod" title="Search User">
<asp:UpdatePanel runat="server" ID="Searchpanel" >
<ContentTemplate>
<table>
<tr>
<td><label class="label">By First Name</label></td>
<td><asp:TextBox ID="txtfn" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Last Name</label></td>
<td><asp:TextBox ID="txtln" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Address</label></td>
<td><asp:TextBox ID="txtadd" runat="server" class="basetxt"></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Mobile</label></td>
<td><asp:TextBox ID="txtmobile" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><table>
<tr>
<td><asp:Button ID="btnSearch" runat="server" CausesValidation="false" Text="Search" class="submitbtn" onclick="btnSearch_Click" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><asp:UpdateProgress ID="updateprogress1" runat="server" AssociatedUpdatePanelID="Searchpanel" cla>
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
this is what I tried but i think its not working
Button:
protected void btnSearch_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
SqlCommand com = new SqlCommand("find", con);
com.Parameters.Add("@firstname", SqlDbType.VarChar).Value = txtfn.Text;
com.Parameters.Add("@lastname", SqlDbType.VarChar).Value = txtln.Text;
com.Parameters.Add("@address", SqlDbType.VarChar).Value = txtadd.Text;
com.Parameters.Add("@mobile", SqlDbType.VarChar).Value = txtmobile.Text;
com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sqlda = new SqlDataAdapter(com);
dt.Clear();
sqlda.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
The updatepanel needs to be on the outside of div#Searchprod. The way you have it now, I don't think div#Searchprod will close.
<asp:UpdatePanel runat="server" ID="Searchpanel" >
<ContentTemplate>
<div id="Searchprod" title="Search User">
<table>
<tr>
<td><label class="label">By First Name</label></td>
<td><asp:TextBox ID="txtfn" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Last Name</label></td>
<td><asp:TextBox ID="txtln" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Address</label></td>
<td><asp:TextBox ID="txtadd" runat="server" class="basetxt"></asp:TextBox></td>
</tr>
<tr>
<td><label class="label">By Mobile</label></td>
<td><asp:TextBox ID="txtmobile" runat="server" class="basetxt" ></asp:TextBox></td>
</tr>
<tr>
<td><table>
<tr>
<td><asp:Button ID="btnSearch" runat="server" CausesValidation="false" Text="Search" class="submitbtn" onclick="btnSearch_Click" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><asp:UpdateProgress ID="updateprogress1" runat="server" AssociatedUpdatePanelID="Searchpanel" cla>
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress></td>
</tr>
</table>
</ContentTemplate>
</div>
</asp:UpdatePanel>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.