Suresh, here's the whole thing:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.DropDownList" %>
<%@ Page Language="VB" Debug="true" %>
<script runat="server" language="VB">
Protected _sqlStmt As String = _
"SELECT c1.clnName as Community, s1.clnGUID, s1.clnPriorityCorrectedTC as
Impact, PopulationKeyInfo = ISNULL(s1.clnPopulationKeyInfo,0),
MinedAreaVictimCount = ISNULL(mavc1.MinedAreaVictimCount,0), nonRecentVictim
= ISNULL(s1.clnVictimOldKilled + s1.clnVictimOldInjured, 0), SHACount =
ISNULL(mavc1.SHACount,0), clnEconomicBaseTC =
ISNULL(s1.clnEconomicBaseTC,'None specified'), MinDistance =
ISNULL(sha1.MinDistance, 0), VictimAssist = ISNULL(mavc1.VictimAssist,
'No'), clnMADoneTC = ISNULL(s1.clnMADoneTC,'Unknown') FROM tblSurvey1 s1
INNER JOIN tblCity c1 ON s1.clnNearestCityGUID = c1.clnGUID INNER JOIN
vwMinDistancesToNearestSHA sha1 ON s1.clnGUID = sha1.clnSurveyGUID LEFT
OUTER JOIN vwMinedAreaVictimCount mavc1 ON s1.clnGUID = mavc1.clnGUID WHERE
s1.clnPriorityCorrectedTC <> 'None'"
Protected _sqlStmt5 As String = _
"SELECT c1.clnName, s1.clnGUID FROM tblSurvey1 s1 INNER JOIN tblCity c1 ON
s1.clnNearestCityGUID = c1.clnGUID ORDER BY c1.clnName"
'Protected WithEvents ddlCommunities As
System.Web.UI.WebControls.DropDownList
Sub Page_Load(Source As Object, E As EventArgs)
'If Not Page.IsPostBack Then
BindData()
'End If
End Sub
Sub BindData()
Dim conString As String = "server=server;database=db;uid=user;pwd=pwd;"
Dim myDataSet1 As New DataSet
Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
myDataAdapter1.Fill(myDataSet1, "CommunitiesT1")
DataGrid2.DataSource = myDataSet1.Tables("CommunitiesT1")
Dim myDataSet5 As New DataSet
Dim myDataAdapter5 As New SqlDataAdapter(_sqlStmt5, conString)
myDataAdapter5.Fill(myDataSet5, "CommunitiesT2")
ddlCommunities.DataSource = myDataSet5.Tables("CommunitiesT2")
ddlCommunities.DataMember = "CommunitiesT2"
ddlCommunities.DataTextField = "clnName"
ddlCommunities.DataValueField = "clnGUID"
DataGrid2.DataBind()
ddlCommunities.DataBind()
End Sub
Sub SortCommand_OnClick(Source As Object, E As
DataGridSortCommandEventArgs)
_sqlStmt = _sqlStmt & " ORDER BY " & E.SortExpression
BindData()
End Sub
Sub PageIndexChanged_OnClick(Source As Object, E As
DataGridPageChangedEventArgs)
DataGrid2.CurrentPageIndex = E.NewPageIndex
BindData()
End Sub
Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
_sqlStmt = _sqlStmt & " AND s1.clnGUID =
'"+ddlCommunities.SelectedItem.Value+"'"
BindData()
End Sub
</script>
<html>
<head>
<title></title>
<style>
.DataGrid {font:x-small Verdana, Arial, sans-serif}
</style>
<LINK rel="stylesheet" href="../Styles.css" type="text/css">
</head>
<body>
<asp:dropdownlist Font-Size="8" id="ddlCommunities" runat="server"
Width="100"></asp:dropdownlist></td>
<ASP:Button id="cmdRunReport" Text="Run Report" runat="server"
onclick="RunReport_OnClick" />
<asp
ataGrid
AllowCustomPaging="false"
AllowPaging="true"
AllowSorting="true"
AlternatingItemStyle-BackColor="#EFEFEF"
AutoGenerateColumns="false"
Border="0"
Cellpadding="4"
Cellspacing="0"
CssClass="DataGrid"
DataKeyField="clnGUID"
Enabled="true"
EnableViewState="true"
HeaderStyle-BackColor="Black"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="White" id="DataGrid2" runat="server"
ShowFooter="false"
OnSortCommand="SortCommand_OnClick"
OnPageIndexChanged="PageIndexChanged_OnClick"
PageSize="50"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Right"
ShowHeader="true"
<SelectedItemStyle Font-Bold="True" ForeColor="#663399"
BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle Font-Size="8pt" Font-Names="Verdana" ForeColor="#330099"
BackColor="White"></ItemStyle>
<HeaderStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True"
HorizontalAlign="Center" ForeColor="#FFFFCC"
BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Community"
DataNavigateUrlFormatString="clnGUID" DataTextField="Community"
Visible="true" NavigateUrl="http://{cgi.server_name}/c={clnGUID}"
SortExpression="Community"
HeaderText="Community" text="Community" runat="server">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle HorizontalAlign="Left"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="Impact" SortExpression="Impact"
HeaderText="Impact"></asp:BoundColumn>
<asp:BoundColumn DataField="PopulationKeyInfo"
SortExpression="PopulationKeyInfo" HeaderText="Population<br>Key
Info"></asp:BoundColumn>
<asp:BoundColumn DataField="MinedAreaVictimCount"
SortExpression="MinedAreaVictimCount"
HeaderText="Recent<br>Victims"></asp:BoundColumn>
<asp:BoundColumn DataField="SHACount" SortExpression="SHACount"
HeaderText="No. of<br>SHA's"></asp:BoundColumn>
<asp:BoundColumn DataField="clnEconomicBaseTC"
SortExpression="clnEconomicBaseTC"
HeaderText="Economic<br>Base"></asp:BoundColumn>
<asp:BoundColumn DataField="clnMADoneTC" SortExpression="clnMADoneTC"
HeaderText="Mine Risk<br>Education"></asp:BoundColumn>
<asp:BoundColumn DataField="VictimAssist" SortExpression="VictimAssist"
HeaderText="Victim<br>Assist"></asp:BoundColumn>
<asp:BoundColumn DataField="MinDistance" SortExpression="MinDistance"
HeaderText="Min Distance<br>to SHA"></asp:BoundColumn>
</columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099"
Position="TopAndBottom" BackColor="#FFFFCC"
Mode="NumericPages"></PagerStyle>
</asp
ataGrid>
</form>
</body>
</html>