I am trying to bind the data to gridView. I basically want to record specific individuals in gridview so that I can get data through query. I also set up AutoGenerateColumns = True
. My code is okay, but there is no exception and there is no error please check and guide. Thank you.
using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Data.SqlClient; Using System.configuration; Using System.Data; Public partial class ViewRegisteredDonors: System.Web.UI.Page {protected void Button1_Click (object sender, EventArgs e) {SqlConnection conec = new SqlConnection (ConfigurationManager.ConnectionStrings [ "BloodDonorRegistrationConnectionString"] ConnectionString.); String query; Query = "D_FirstName, D_LastName, D_BloodGroup, D_City, D_Phone selector where D_City = @BG and D_City = @cc"; SqlCommand CMD = New SQL Commands (Query, Conoc); Cmd.Parameters.AddWithValue ("@BG", DropBordBlood.updated.team); Cmd.Parameters.AddWithValue ("cc", DropDownListCity.SelectedItem.Text); Conec.Open (); Cmd.CommandType = CommandType.Text; //cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = New SqlDataAdapter (cmd); Dataset d = new dataset (); Da.Fill (d); GridView1.DataSource = D; GridView1.DataBind (); }}
Check your parameter name @ CC. @missing then your dataset can be. Empty should
cmd.Parameters.AddWithValue ( "CC", DropDownListCity.SelectedItem.Text);
cmd.Parameters.AddWithValue ( "@ cc", dropdown list cit. Selected Iteem.Text);
No comments:
Post a Comment