I need to show a message as a label whenever user selecct To year less than from year.
I have created a label "lblYrChk" --doesn't work .
what i am doing wrong.
Pl. help.
<asp:ObjectDataSource ID="Srcfmyr" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="HITS.App_code.stateTableAdapters.SOURCE_YEAR_VWTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="RBl1" Name="myType"
PropertyName="SelectedValue" Type="String" DefaultValue="G" />
</SelectParameters>
</asp:ObjectDataSource>
From: <asp:DropDownList ID="ddlyr" runat="server"
OnSelectedIndexChanged="ddlyr_SelectedIndexChanged"
AutoPostBack="True" DataSourceID="Srcfmyr"
DataTextField="SOURCE_YEAR"
DataValueField="SOURCE_YEAR" Font-Underline="False" >
</asp:DropDownList>
<asp:ObjectDataSource ID="SrcToyr" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="HITS.App_code.stateTableAdapters.SOURCE_YEAR_VWTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="RBl1"
DefaultValue="G" Name="myType"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:Label ID="lblTo" runat ="server" Text="To:"></asp:Label>
<asp:DropDownList ID="ddlTo" runat="server"
AutoPostBack="True" DataSourceID="Srcfmyr"
DataTextField="SOURCE_YEAR"
DataValueField="SOURCE_YEAR"
Font-Underline="False"
OnSelectedIndexChanged="ddlTo_Clicked" >
</asp:DropDownList>
<br />
<asp:Label ID="lblYrChk" runat="server" Text=" " ForeColor="#993300"></asp:Label>
</td>
And in C#
protected void ddlyr_SelectedIndexChanged(object sender, EventArgs e)
{
Int16 fmyr = Convert.ToInt16(ddlyr.SelectedValue);
Int16 toyr = Convert.ToInt16(ddlTo.SelectedValue);
if (fmyr > toyr)
{
lblYrChk.Text = "**Check Years**";
}
else
lblYrChk.Text = "";
sSQL += "AND SOURCE_YEAR ='" + ddlyr.SelectedItem.ToString() + "'";
MakeSQL();
}
protected void ddlTo_Clicked(object sender, EventArgs e)
{
string sSQLfy = "";
string toval = ddlTo.SelectedItem.ToString();
string fmval = ddlyr.SelectedItem.ToString();
if (ddlTo.SelectedIndex != -1)
{
Int16 fmyr = Convert.ToInt16(ddlyr.SelectedValue);
Int16 toyr = Convert.ToInt16(ddlTo.SelectedValue);
if (toyr > fmyr)
{
lblYrChk.Text = "**Check Years**";
}
else
lblYrChk.Text = "";
sSQLfy = "AND SOURCE_YEAR between '" + toval + "' AND '" + fmval + "'";
sSQL =sSQLfy.ToString();
MakeSQL();
}
}