I've added a radiobutton List and a gridview to the page:
<asp:RadioButtonList ID="Pending" runat="server" AutoPostBack="True" >
<asp:ListItem Value="300">Over 300</asp:ListItem>
<asp:ListItem Value="350">Over 350</asp:ListItem>
<asp:ListItem Value="400">Over 400</asp:ListItem>
</asp:RadioButtonList>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource7" EnableModelValidation="True" Width="331px"
CaptionAlign="Top" Height="126px" BackColor="White" BorderColor="#DCBE68"
BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
HorizontalAlign="Center" CellSpacing="2" Font-Names="Arial"
AllowSorting="True">
<Columns>
<asp:BoundField DataField="Doc" HeaderText="DDS" SortExpression="Doc" />
<asp:TemplateField HeaderText="Total Pending" SortExpression="cnt">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# "PendingDDS.aspx?doc=" & Eval("doc") %>'
Text='<%# Eval("cnt") %>'></asp:HyperLink>
</ItemTemplate>
<HeaderStyle Wrap="False" />
</asp:TemplateField>
</Columns>
</asp:GridView>
When the page loads it shows one data. I want to be able to click on the listitem 300 and have the same gridview load with new data.
I added this to the code behind:
Protected Sub Pending_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Pending.SelectedIndexChanged
Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("PendingConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
Dim cmdPending As New Data.SqlClient.SqlCommand
With cmdPending
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "Get301"
.Connection = conn
If Pending.SelectedItem.Value = "300" And Request.QueryString = "F03" Then
.Parameters.AddWithValue("@doc", Pending.SelectedValue)
End If
End With
Dim adapter As New Data.SqlClient.SqlDataAdapter(cmdPending)
Try
conn.Open()
Dim ds As New Data.DataSet
adapter.Fill(ds)
'GridView1.DataSource = ds
GridView1.DataBind()
Finally
conn.Dispose()
End Try
End Sub
I have the blue squiggly line under request.querystring ="F03" (saying overload resolution failed) What am I doing wrong?
Here's the stored procedure:
if @doc = 'F03'
begin
SELECT
doc,
COUNT(*) AS cnt
FROM
(
Select
doc
FROM pendingdds p
join Offices.dbo.OfficeCodes d
on d.officecode = p.doc
where d.typecode='7' and d.reportsto='F03'
and ( Datediff(DAY, filedate, Getdate()) > 249 )
AND ( Datediff(DAY, filedate, Getdate()) < 301)
Group By
doc, clm, filedate
) AS T
GROUP BY
doc
end
What am I doing wrong or is the the right way to do it?