Note that there are some explanatory texts on larger screens.

plurals
  1. POClick Button - No Action
    primarykey
    data
    text
    <p>I am trying to retrieve information from database. User enters id of the person he is looking for to ID textbox, than press display button. The grid view should show the result. But when button is pressed, nothing happens. Could anyone help or tell me what I should check? Code for button: </p> <pre><code>protected void btnDisplay_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source="Name";Initial Catalog="Name";Integrated Security=True"); SqlCommand cmd = new SqlCommand("displayData", conn); conn.Open(); cmd.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = Convert.ToInt32(txtID.Text); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader rd = cmd.ExecuteReader(); grvResults.DataSource = rd; grvResults.DataBind(); } </code></pre> <p>Here is stored procedure:</p> <pre><code>USE ["Name"] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[displayData] (@ID int) as begin SELECT * FROM Customers WHERE ID = @ID end </code></pre> <p>Here is display data method:</p> <pre><code>public List&lt;Customer&gt; displayData() { List&lt;Customer&gt; lst = new List&lt;Customer&gt;(); SqlConnection conn = new SqlConnection("Data Source="Name";Initial Catalog="Name";Integrated Security=True"); SqlCommand cmd = new SqlCommand("Select * From Customers", conn); conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { lst.Add(new Customer() { ID = rd.GetInt32(0), FName = rd.GetString(1), LName = rd.GetString(2) }); } return lst; } </code></pre> <p>aspx for button:</p> <pre><code>&lt;asp:Button ID="btnDisplay" runat="server" Text="Display" OnClick="btnDisplay_Click" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload