Hi @Baiju EP ,
You can provide an example or error message that reproduces the problem.
I wrote an example based on your description, I hope it will help you.
<div>
<asp:DropDownList ID="mth" runat="server">
<asp:ListItem>Select mouth</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="yrtxt" runat="server">
<asp:ListItem>Select year</asp:ListItem>
<asp:ListItem>2021</asp:ListItem>
<asp:ListItem>2022</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBCS %>"
></asp:SqlDataSource>
</div>
Protected Sub Button1_Click(sender As Object, e As EventArgs)
SqlDataSource1.SelectCommand = "SELECT Empno, Name ,Medicine ,qty ,effdate from Clinic_Med_Issue where Month(effdate) ='" & mth.SelectedItem.ToString() & "' and Year(effdate) ='" & yrtxt.SelectedItem.Value.ToString() & "'"
GridView1.DataSource = SqlDataSource1
GridView1.DataBind()
End Sub
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.