Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
XML
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="Data Source=xxx;Initial Catalog=dbxx;Integrated Security=True"
            SelectCommand="SELECT dName,dRegno,dGender,dSpeciality,dExperience,dLanguages FROM Doctor WHERE dName='"&txbxDoctorNameVal.Text&"'">
</asp:SqlDataSource>




i need to get name from text box and the matching rows must show in a gridview....
i wrote this but an error occured "The server tag is not well form"..
if any one knw what is the wrong with my code tell me..

thanx
Posted
Updated 9-Jul-11 5:39am
v2

1 solution

You can use the below way.
<asp:sqldatasource id="SqlDataSource2" runat="server" xmlns:asp="#unknown">
ConnectionString="Data Source=xxx;Initial Catalog=dbxx;Integrated Security=True"
SelectCommand="SELECT dName,dRegno,dGender,dSpeciality,dExperience,dLanguages FROM Doctor WHERE dName=@dName">
  <selectparameters>
    <asp:controlparameter controlid="txbxDoctorNameVal" name="dName" propertyname="Text" />
  </selectparameters>
</asp:sqldatasource>


Further reading
Using Parameterized Queries with the SqlDataSource[^]
Inserting, Updating, and Deleting Data with the SqlDataSource[^]
Dynamically Assign Parameter to SqlDataSource Parameter Collection[^]
 
Share this answer
 
Comments
madhu_ 9-Jul-11 12:43pm    
thanx for ur solution... i tried lot to find this....
thatraja 9-Jul-11 12:44pm    
You welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900