TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
veena
NA
29
2.1k
not displaying gridview
Dec 18 2015 11:52 PM
Hi,
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="test.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="jquery-1.11.3.js"></script>
<link href="css/StyleSheet1.css" rel="stylesheet" />
</head>
<body>
<div>
<form id="form1" runat="server">
<div style='float:right;text-align:right;width:50%'>
<asp:DropDownList ID="ddldistrict" runat="server" Width="150px" AutoPostBack = "true" OnSelectedIndexChanged="ddldistrict_SelectedIndexChanged">
<asp:ListItem Text = "--Select District--" Value = ""></asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:DropDownList ID="ddltaluk" runat="server" Enabled = "false" Width="150px" AutoPostBack = "true" OnSelectedIndexChanged="ddltaluk_SelectedIndexChanged">
<asp:ListItem Text= "--Select Taluk--" Value = ""></asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:GridView ID="GridView1" runat="server" HorizontalAlign="right"></asp:GridView>
</div>
</form>
<asp:Label ID="Label1" runat="server" Text="Select Layers"></asp:Label>
<div class="checkbox" style='float:left;width:50%'>
<ul>
<li><input type="checkbox" value="0" onclick="layer(this)"/>District</li>
<li><input type="checkbox" value="1" onclick="layer(this)"/>Taluk</li>
<li><input type="checkbox" value="2" onclick="layer(this)"/>Village</li>
<li><input type="checkbox" value="3" onclick="layer(this)"/>Powerline</li>
<li><input type="checkbox" value="4" onclick="layer(this)"/>Road</li>
<li><input type="checkbox" value="5" onclick="layer(this)"/>School</li>
</ul>
</div>
</div>
<div id="map"></div>
<script src="js/JavaScript1.js"></script>
</body>
</html>
here is 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;
using Npgsql;
namespace test
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddldistrict.AppendDataBoundItems = true;
string sQuery = "SELECT districtna,districtco FROM district";
string sConn = "Server=192.168.1.99;Port=5433;User Id=postgres;Password=user;Database=school;";
DataTable DT = new DataTable();
NpgsqlConnection Conn = new NpgsqlConnection(sConn);
Conn.Open();
DataSet DS = new DataSet("DS1");
NpgsqlDataAdapter DA = new NpgsqlDataAdapter();
DA.SelectCommand = new NpgsqlCommand(sQuery, Conn);
DA.Fill(DS);
ddldistrict.DataTextField = "districtna";
ddldistrict.DataSource = DS;
ddldistrict.DataBind();
Conn.Close();
}
}
protected void ddldistrict_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddldistrict.SelectedIndex == 0)
{
ddltaluk.Enabled = false;
ddltaluk.Items.Clear();
ddltaluk.Items.Insert(0, new ListItem("--Select Taluk--", "-1"));
GridView1.DataSource = null;
GridView1.DataBind();
}
else
{
ddltaluk.Enabled = true;
string sQuery = "SELECT talukname,talukcode FROM taluk";
string sConn = "Server=192.168.1.99;Port=5433;User Id=postgres;Password=user;Database=school;";
NpgsqlConnection Conn = new NpgsqlConnection(sConn);
Conn.Open();
DataSet DS = new DataSet("DS2");
NpgsqlDataAdapter DA = new NpgsqlDataAdapter();
DA.SelectCommand = new NpgsqlCommand(sQuery, Conn);
DA.Fill(DS);
ddltaluk.AppendDataBoundItems = true;
ddltaluk.DataSource = DS;
ddltaluk.DataValueField = "talukname";
ddltaluk.DataTextField = "talukname";
ddltaluk.DataBind();
//GridView1.DataSource = null;
//GridView1.DataSource = DS;
//GridView1.DataBind();
ddltaluk.ClearSelection();
Conn.Close();
}
}
protected void ddltaluk_SelectedIndexChanged(object sender, EventArgs e)
{
string sQuery = "SELECT talukcode,talukname,districtco,statecode,shape_leng,shape_area FROM taluk WHERE talukcode='"+ ddltaluk.SelectedValue +"'";
string sConn = "Server=192.168.1.99;Port=5433;User Id=postgres;Password=user;Database=school;";
NpgsqlConnection Conn = new NpgsqlConnection(sConn);
Conn.Open();
DataSet DS = new DataSet("DS2");
NpgsqlDataAdapter DA = new NpgsqlDataAdapter();
DA.SelectCommand = new NpgsqlCommand(sQuery, Conn);
DA.Fill(DS);
GridView1.DataSource = null;
GridView1.DataSource = DS;
GridView1.DataBind();
Conn.Close();
}
}
}
its not displaying grid view. can anybody tell me or help to display.
Reply
Answers (
1
)
Button Click event with if statement.
how to check the value in the text-box is a bar-code value?