Compiler Error

Jul 13 2015 6:57 AM
how to solved bellow maintain error
 
Compiler Error Message: CS1061: 'ASP.empdetailsfromdb_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.empdetailsfromdb_aspx' could be found (are you missing a using directive or an assembly reference?)
 
here is my design code
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="empdetailsfromdb.aspx.cs" Inherits="csvfileupload2.empdetailsfromdb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="height: 415px">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="select city"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="select first_name"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="search" />
<br />
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanged="GridView1_SelectedIndexChanged">
</asp:GridView>
</div>
</form>
</body>
</html>
 
and here is my back end code
 
 
using 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;
using System.IO;
namespace csvfileupload2
{
public partial class empdetailsfromdb : System.Web.UI.Page
{
string str = "Data Source=ANIRUDDHA-PC;Initial Catalog=sark;Integrated Security=True";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String strQuery = "SELECT distinct (city) FROM profilesrr";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "city";
DropDownList1.DataValueField = "city";
DropDownList1.DataBind();
// DropDownList2.SelectedIndex = 1;
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
// con.Dispose();
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
String strQuery = "SELECT distinct (first_name) FROM profilesrr";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
DropDownList2.DataSource = cmd.ExecuteReader();
DropDownList2.DataTextField = "first_name";
DropDownList2.DataValueField = "first_name";
DropDownList2.DataBind();
// DropDownList2.SelectedIndex = 1;
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "Data Source=ANIRUDDHA-PC;Initial Catalog=sark;Integrated Security=True";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("select * from profilesrr where city = '" + DropDownList1.SelectedValue + "' and first_name='" + DropDownList2.SelectedValue + "'", con);
SqlDataAdapter Adpt = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
Adpt.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
//code for DropDownList2_SelectedIndexChanged
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
 
please help me 
 

Answers (20)