Please assist me with this as I am lost.
Here's my datalist:
<asp:RadioButtonList ID="Pending" runat="server" AutoPostBack="True" OnSelectedIndexChanged ="PopulateGrid">
<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>
Here's the code behind:
Protected Sub PopulateGrid(ByVal sender As Object, ByVal e As EventArgs)
Select Case Pending.SelectedItem.Value Case "300"
Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("PendingClaimsConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
Dim cmdPending As New Data.SqlClient.SqlCommand
With cmdPending
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetDDS250"
.Connection = conn
.Parameters.AddWithValue("@doc", Pending.SelectedValue)
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
Exit Select Case "350"
GridView1.DataSource = "" GridView1.DataBind()
Exit Select Case "400"
GridView1.DataSource = "" GridView1.DataBind()
Exit Select End Select End Sub
I'm getting this error message:
Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
Here's the querystring (url) http://localhost:57710/PendingPDF.aspx?doc=F03
Here's how I wrote my stored procedure:
If doc is F03 and if you select radiolist 300 then run the first if else statement:
ALTER procedure [dbo].[GetDDS250]@doc varchar(3)asif @doc = 'F03' beginSELECT
doc, COUNT(*) AS cntFROM ( Select doc
FROM pendingdds pjoin Offices.dbo.OfficeCodes don 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, filedate ) AS TGROUP BY docendif @doc = 'V01' begin
SELECT doc, COUNT(*) AS cntFROM ( Select doc
FROM pendingdds pjoin Offices.dbo.OfficeCodes don d.officecode = p.doc
where doc in ('V01', 'S67', 'S41', 'S66')
and ( Datediff(DAY, filedate, Getdate()) > 249 )
AND ( Datediff(DAY, filedate, Getdate()) < 301) Group By
doc ) AS TGROUP BY docendif @doc = 'S88' beginSELECT
doc, COUNT(*) AS cntFROM ( Select doc
FROM pendingdds pjoin Offices.dbo.OfficeCodes don d.officecode = p.doc
where doc in ('S88', 'S53', 'S10', 'S92', 'S93','S0L')
and ( Datediff(DAY, filedate, Getdate()) > 249 )
AND ( Datediff(DAY, filedate, Getdate()) < 301) Group By
doc ) AS TGROUP BY docend