.aspx PAGE
==============================================================================
<asp:GridView ID="GridViewActiveCampaigns" runat="server" AutoGenerateColumns="False" DataKeyNames="CampaignId"
OnRowDataBound="GridViewActiveCampaigns_OnDataBound" GridLines="Both">
<Columns>
<asp:BoundField DataField="CampaignName" HeaderText="Campaign Name" />
<asp:TemplateField HeaderText="Raised">
<ItemTemplate>
<asp:Literal ID="LiteralGoalAmount" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Days left">
<ItemTemplate>
<asp:Literal ID="LiteralDaysLeft" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Donars">
<ItemTemplate>
<asp:Literal ID="LiteraltotalDonars" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
========================================================
C# Code(Back end)
List<Campaign> CampaignList = new CampaignBLL().GetAllCampaigns();
GridViewActiveCampaigns.DataSource = CampaignListSelected;
protected void GridViewActiveCampaigns_OnDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Campaign campaign = e.Row.DataItem as Campaign;
Literal LiteralGoalAmount = e.Row.FindControl("LiteralGoalAmount") as Literal;
LiteralGoalAmount.Text = campaign.GoalAmount.Value.ToString("C");
Literal LiteralDaysLeft = e.Row.FindControl("LiteralDaysLeft") as Literal;
//LiteralDaysLeft.Text = campaign.GoalAmount.Value.ToString("C");
int differenceInDays = GetDifferenceOfDate(campaign);
LiteralDaysLeft.Text = differenceInDays.ToString() + " Days";
int totalDonars = 0;
decimal calculateRaised = CalculateRaised(campaign.CampaignId, out totalDonars);
Literal LiteraltotalDonars = e.Row.FindControl("LiteraltotalDonars") as Literal;
LiteraltotalDonars.Text = totalDonars.ToString();
}
}
========================================================
No comments:
Post a Comment