Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
1
Answer
how to update dataset n gridview each time data is loaded
zenani mthembu
5y
483
1
Reply
i am developing a small website where users first upload excel sheet with project names, the next page i have a gridview which displays results of stored procedure Report. the report shows learners extracted from the database using the project names. the problem i have is that when i upload new projects the gridview shows the old data or is empty. i tried to truncate the table first then run the procedure but then my gridview is empty. here is the code and stored procedure. would really appreciate the help
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
bind();
}
}
public
void
bind(){
SqlConnection con =
new
SqlConnection(strConnString);
con.Open();
SqlCommand command =
new
SqlCommand(
"BenReport"
, con) { CommandType = System.Data.CommandType.StoredProcedure };
SqlDataAdapter sda =
new
SqlDataAdapter(
"BenReport"
, con);
command.Connection = con;
sda.SelectCommand = command;
DataSet ds =
new
DataSet();
sda.Fill(ds);
GRDBencount.DataSource = ds.Tables[0];
GRDBencount.DataBind();
con.Close();
}
stored procedure
ALTER
PROCEDURE
BenReport
AS
INSERT
INTO
[Verify_Pbank_Projects_MassT]
SELECT
DISTINCT
master.id,PPRS.PPR_Caption ,
CAST
(
replace
(
substring
(PPR_Caption,1,CHARINDEX(
'['
,PPR_Caption)),
'['
,
''
)
AS
DATE
)
AS
UPLOAD_DATE,PPRS.[Upload_Date]
From
PPRS
left
join
master
on
PPRS.PPR_Caption = masters.Caption
WHERE
PPR_Caption
IN
(
SELECT
DISTINCT
master.Caption
FROM
master)
--- Report show counts for beneficiaries to be extracted and excluded
SELECT
G.ParentId ,(
Select
Caption
from
Master
Where
ID = G.ParentId)
as
PPRName,
COUNT
(
DISTINCT
G.Field_972)
as
BeneficiaryCnt ,
SUM
(
CASE
WHEN
( (G.AccountNumber
IS
NOT
NULL
AND
G.AccountNumber <> 0)
AND
NOT
((
ISNULL
(
cast
(ROUND(G.FIELD_647,0)
as
decimal
(18,0)),0)+
ISNULL
(
cast
(ROUND(G.FIELD_649,0)
as
decimal
(18,0)),0)+
ISNULL
(
cast
(ROUND(G.FIELD_1233,0)
as
decimal
(18,0)),0)) *
ISNULL
(
cast
(ROUND(G.FIELD_648,2)
as
decimal
(18,2)),0)) = 0 )
THEN
1
ELSE
0
END
)
as
Ben_Account_Included,
SUM
(
CASE
WHEN
NOT
(G.AccountNumber
IS
NOT
NULL
AND
G.AccountNumber <> 0)
THEN
1
ELSE
0
END
)
as
Ben_ZeroAccount_Excluded,
SUM
(
CASE
WHEN
((
ISNULL
(
cast
(ROUND(G.FIELD_647,0)
as
decimal
(18,0)),0)+
ISNULL
(
cast
(ROUND(G.FIELD_649,0)
as
decimal
(18,0)),0)+
ISNULL
(
cast
(ROUND(G.FIELD_1233,0)
as
decimal
(18,0)),0)) *
ISNULL
(
cast
(ROUND(G.FIELD_648,2)
as
decimal
(18,2)),0)) = 0
THEN
1
ELSE
0
END
)
as
Ben_ZeroWages_Excluded
FROM
pb_g164 G
with
(nolock)
INNER
JOIN
P_data_search
with
(nolock)
ON
P_data_search.RecordID =
cast
(G.FIELD_972
as
int
)
INNER
JOIN
C_ListItems
with
(nolock)
ON
C_ListItems.ItemID =
cast
(G.FIELD_645
as
int
)
INNER
JOIN
(
SELECT
m2.id
as
PPR_Recordid,m2.Caption,
CAST
(
Substring
(m2.Caption, 1,Charindex(
'['
, m2.Caption)-1)
as
date
) PPRDate
FROM
dbo.Masterm
with
(nolock)
INNER
JOIN
dbo.Master m1
with
(nolock)
on
m.ID=m1.ParentRecordID
and
m1.TypeID=77
INNER
JOIN
dbo.Master m2
with
(nolock)
on
m1.ID=m2.ParentRecordID
and
m2.TypeID=82
and
m2.TransactionID>1
INNER
JOIN
dbo.Master_Status ms
on
m.Status=ms.Status
INNER
JOIN
dbo.Master_Status msp
on
m2.Status=msp.Status
INNER
JOIN
dbo.[Verify_Pbank_Projects_MassT] vp
with
(nolock)
on
vp.PPRName = m2.Caption
AND
vp.PPRDate =
CAST
(
Substring
(m2.Caption, 1,Charindex(
'['
, m2.Caption)-1)
as
DateTime)
WHERE
m.TypeID=72
) pb
ON
pb.PPR_Recordid = G.ParentId
WHERE
G.isActive = 1
and
G.Status =
'C'
--AND ( G.Paid = 0 OR G.Paid IS NULL)
group
by
G.ParentId
--END
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
how to give default value to gridview ?
How to create dynamic crystal report with send parameter