Brian
asked on
GridView Total Field
Hello,
Is there a way to include a Total field below all of the data from the BoundFields? Example below.
Column 1 Column 2
User1 $5
User2 $10
Total: $15
Is there a way to include a Total field below all of the data from the BoundFields? Example below.
Column 1 Column 2
User1 $5
User2 $10
Total: $15
ASKER
Hi guru_sami,
Anyway you could help me determine where I need to implement the footer template? I do know that It needs to be the footer for the gvOrders GridView.
<asp:Panel CssClass="grid" ID="pnlCust" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False "
runat="server" OnRowDataBound="gvCustomer s_RowDataB ound"
CellPadding="4" EnableModelValidation="Tru e" ForeColor="#5A5A5A"
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png" runat="server" />
<span class="header"><%#Eval("CO URSE_NAME" )%></span>
</asp:Panel>
<div id="menu">
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False " CssClass="grid" ID="gvOrders"
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="true"
EnableModelValidation="Tru e" ForeColor="#333333" Width="400px">
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<%--<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<ItemStyle CssClass="rownum" />--%>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</asp:Panel>
</div>
<asp:CollapsiblePanelExten der ID="cpe" runat="Server" TargetControlID="pnlOrders " CollapsedSize="0" Collapsed="True" ExpandControlID="pnlCustom er"
CollapseControlID="pnlCust omer" AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollaps ible"
ExpandedImage="~/minus_sig n.png" CollapsedImage="~/plus_sig n.png" ExpandDirection="Vertical" >
</asp:CollapsiblePanelExte nder>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea der"
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea dernopad" Height="20px"
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Anyway you could help me determine where I need to implement the footer template? I do know that It needs to be the footer for the gvOrders GridView.
<asp:Panel CssClass="grid" ID="pnlCust" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False
runat="server" OnRowDataBound="gvCustomer
CellPadding="4" EnableModelValidation="Tru
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png"
<span class="header"><%#Eval("CO
</asp:Panel>
<div id="menu">
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="true"
EnableModelValidation="Tru
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<%--<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<ItemStyle CssClass="rownum" />--%>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</asp:Panel>
</div>
<asp:CollapsiblePanelExten
CollapseControlID="pnlCust
ExpandedImage="~/minus_sig
</asp:CollapsiblePanelExte
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
following the link i provide earlier you need to add this to your<Columns> of gvOrders:
<FooterTemplate>
<%# GetTotal().ToString("N2") %>
</FooterTemplate>
Here is one more sample: http://msdn.microsoft.com/en-us/library/ms972833.aspx
<FooterTemplate>
<%# GetTotal().ToString("N2") %>
</FooterTemplate>
Here is one more sample: http://msdn.microsoft.com/en-us/library/ms972833.aspx
ASKER
Ok, I applied the footer in the gvOrders GridView like you should and like the tutorial displayed but it's not showing up and I even added ShowFooter="true" on that GridView. Please see where I added the Footer.
<asp:Panel CssClass="grid" ID="pnlCust" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False "
runat="server" OnRowDataBound="gvCustomer s_RowDataB ound"
CellPadding="4" EnableModelValidation="Tru e" ForeColor="#5A5A5A"
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png" runat="server" />
<span class="header"><%#Eval("CO URSE_NAME" )%></span>
</asp:Panel>
<div id="menu">
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False " CssClass="grid" ID="gvOrders"
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="true"
EnableModelValidation="Tru e" ForeColor="#333333" Width="400px">
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<%--<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<ItemStyle CssClass="rownum" />--%>
<FooterTemplate>
<%#Eval("finalpntspossible ")%>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</asp:Panel>
</div>
<asp:CollapsiblePanelExten der ID="cpe" runat="Server" TargetControlID="pnlOrders " CollapsedSize="0" Collapsed="True" ExpandControlID="pnlCustom er"
CollapseControlID="pnlCust omer" AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollaps ible"
ExpandedImage="~/minus_sig n.png" CollapsedImage="~/plus_sig n.png" ExpandDirection="Vertical" >
</asp:CollapsiblePanelExte nder>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea der"
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea dernopad" Height="20px"
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:Panel CssClass="grid" ID="pnlCust" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False
runat="server" OnRowDataBound="gvCustomer
CellPadding="4" EnableModelValidation="Tru
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png"
<span class="header"><%#Eval("CO
</asp:Panel>
<div id="menu">
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="true"
EnableModelValidation="Tru
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<%--<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<ItemStyle CssClass="rownum" />--%>
<FooterTemplate>
<%#Eval("finalpntspossible
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</asp:Panel>
</div>
<asp:CollapsiblePanelExten
CollapseControlID="pnlCust
ExpandedImage="~/minus_sig
</asp:CollapsiblePanelExte
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
ASKER
Hi guru_sami,
Below is an example of what I have so far, however I need to only display the value from the DB and not calcuate on the code, only display FINALGRADEPOSSIBLE from DB in Total field. The GridView below is NOT my GridView it is an example that I found. The field that I need to display from my DB is called FINALGRADEPOSSIBLE.
<script runat="server">
int FINALPNTSPOSSIBLE;
int GetUnitPrice(int Price)
{
FINALPNTSPOSSIBLE += Price;
return Price;
}
int GetTotal()
{
return FINALPNTSPOSSIBLE;
}
</script>
<asp:GridView ID="GridView1" ShowFooter="true" DataKeyNames="ProductId" AutoGenerateColumns="false "
runat="server" DataSourceID="SqlDataSourc e1">
<Columns>
<asp:BoundField DataField="Productid" HeaderText="Product Id" />
<asp:BoundField DataField="ProductName" FooterText="Total" HeaderText="Product Name" />
<asp:TemplateField HeaderText="Unit Price" FooterStyle-Font-Bold="Tru e">
<ItemTemplate>
<%# GetUnitPrice(decimal.Parse (Eval("Uni tPrice").T oString()) ).ToString ("N2") %>
</ItemTemplate>
<FooterTemplate>
<%# GetTotal().ToString("N2") %>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Below is an example of what I have so far, however I need to only display the value from the DB and not calcuate on the code, only display FINALGRADEPOSSIBLE from DB in Total field. The GridView below is NOT my GridView it is an example that I found. The field that I need to display from my DB is called FINALGRADEPOSSIBLE.
<script runat="server">
int FINALPNTSPOSSIBLE;
int GetUnitPrice(int Price)
{
FINALPNTSPOSSIBLE += Price;
return Price;
}
int GetTotal()
{
return FINALPNTSPOSSIBLE;
}
</script>
<asp:GridView ID="GridView1" ShowFooter="true" DataKeyNames="ProductId" AutoGenerateColumns="false
runat="server" DataSourceID="SqlDataSourc
<Columns>
<asp:BoundField DataField="Productid" HeaderText="Product Id" />
<asp:BoundField DataField="ProductName" FooterText="Total" HeaderText="Product Name" />
<asp:TemplateField HeaderText="Unit Price" FooterStyle-Font-Bold="Tru
<ItemTemplate>
<%# GetUnitPrice(decimal.Parse
</ItemTemplate>
<FooterTemplate>
<%# GetTotal().ToString("N2") %>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then adjust your GetTotal function to return value from database...
int GetTotal()
{
//Query your database to get final points and return it.
return FINALPNTSPOSSIBLE;
}
int GetTotal()
{
//Query your database to get final points and return it.
return FINALPNTSPOSSIBLE;
}
ASKER
Ok, this is what I'm using below to retrieve the data. Not sure how to implement that code to retrieve the value. I'll try and see if I can figure it out unless you have time to let me know.
protected void gvCustomers_RowDataBound(o bject sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
{
DataRowView drv = (DataRowView)e.Row.DataIte m;
string COURSE_ID;
COURSE_ID = (string)drv["COURSE_ID"];
string STUDENT_ID;
STUDENT_ID = (string)drv["STUDENT_ID"];
string connString = ConfigurationManager.Conne ctionStrin gs["PACybe r"].Connec tionString ;
SqlConnection conn = new SqlConnection(connString);
string sqlCommandText = "BB_SELECT_ASSIGNMENTS";
SqlCommand cmd = new SqlCommand(sqlCommandText, conn);
cmd.CommandType = CommandType.StoredProcedur e;
//retrieve values for course_id & student_id
cmd.Parameters.AddWithValu e("@COURSE _ID", COURSE_ID);
cmd.Parameters.AddWithValu e("@STUDEN T_ID", STUDENT_ID);
try
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
GridView gvOrders = e.Row.FindControl("gvOrder s") as GridView;
gvOrders.DataSource = reader;
gvOrders.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message) ;
}
finally
{
conn.Close();
}
}
}
protected void gvCustomers_RowDataBound(o
{
if (e.Row.RowType == DataControlRowType.DataRow
{
DataRowView drv = (DataRowView)e.Row.DataIte
string COURSE_ID;
COURSE_ID = (string)drv["COURSE_ID"];
string STUDENT_ID;
STUDENT_ID = (string)drv["STUDENT_ID"];
string connString = ConfigurationManager.Conne
SqlConnection conn = new SqlConnection(connString);
string sqlCommandText = "BB_SELECT_ASSIGNMENTS";
SqlCommand cmd = new SqlCommand(sqlCommandText,
cmd.CommandType = CommandType.StoredProcedur
//retrieve values for course_id & student_id
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
try
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
GridView gvOrders = e.Row.FindControl("gvOrder
gvOrders.DataSource = reader;
gvOrders.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message)
}
finally
{
conn.Close();
}
}
}
from where does the FINALPNTSPOSSIBLE come from?
One other way is as shown in the second link I provided. Inside the RowDataBound check if it is Footer then set the value.
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
e.Row.Cells[1].Text = FINALPNTSPOSSIBLE;
}
One other way is as shown in the second link I provided. Inside the RowDataBound check if it is Footer then set the value.
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
e.Row.Cells[1].Text = FINALPNTSPOSSIBLE;
}
ASKER
>> from where does the FINALPNTSPOSSIBLE come from?
It comes from my DB and the FINALPNTSPOSSIBLE value is include in the BB_SELECT_ASSIGNMENTS Stored Procedure withing the gvCustomers_RowDataBound Event Handler code.
Where should I include the code below at within my code?
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
e.Row.Cells[1].Text = FINALPNTSPOSSIBLE;
}
It comes from my DB and the FINALPNTSPOSSIBLE value is include in the BB_SELECT_ASSIGNMENTS Stored Procedure withing the gvCustomers_RowDataBound Event Handler code.
Where should I include the code below at within my code?
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
e.Row.Cells[1].Text = FINALPNTSPOSSIBLE;
}
not sure I am understanding it right ...but I think it should be going inside gvOrders rowdatabound
so you need to add Onrowdatabound event handler as you have for gvCustomers.
so you need to add Onrowdatabound event handler as you have for gvCustomers.
ASKER
I'm probally not explainging it to you correctly, let me try again.
Do I need to place the code snippet that you supplied within the protected void gvCustomers_RowDataBound code? If so, where at within the gvCustomers_RowDataBound code?
Do I need to place the code snippet that you supplied within the protected void gvCustomers_RowDataBound code? If so, where at within the gvCustomers_RowDataBound code?
No not in gvCustomers_RowDataBound but you have to add similar new handler for your second GV - gvOrders. Then place that code snipped inside that because from your code I understand that the FINALPNTSPOSSIBLE is related to gvOrders and not the main gvCustomers.
ASKER
Ok, If you take a look at the my GridView below that I just made changes to I'm able to retrieve the FINALGRADEPOSSIBLE value without writing any codee, HOWEVER, I can't get that value into the Footer at the bottom. It keeps going into the first column with the other value.
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False "
runat="server" OnRowDataBound="gvCustomer s_RowDataB ound"
CellPadding="4" EnableModelValidation="Tru e" ForeColor="#5A5A5A"
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png" runat="server" />
<span class="header"><%#Eval("CO URSE_NAME" )%></span>
</asp:Panel>
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False " CssClass="grid" ID="gvOrders"
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True"
EnableModelValidation="Tru e" ForeColor="#333333" Width="400px">
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%-- <%# Container.DataItemIndex + 1 %> --%>
</ItemTemplate>
<ItemStyle CssClass="rownum" />
<FooterTemplate>
<%#Eval("finalpntspossible ")%>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</div>
</asp:Panel>
<asp:CollapsiblePanelExten der ID="cpe" runat="Server" TargetControlID="pnlOrders " CollapsedSize="0" Collapsed="True" ExpandControlID="pnlCustom er"
CollapseControlID="pnlCust omer" AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollaps ible"
ExpandedImage="~/minus_sig n.png" CollapsedImage="~/plus_sig n.png" ExpandDirection="Vertical" >
</asp:CollapsiblePanelExte nder>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea der"
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea dernopad" Height="20px"
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
<asp:GridView Width="100%" ID="gvCustomers" AutoGenerateColumns="False
runat="server" OnRowDataBound="gvCustomer
CellPadding="4" EnableModelValidation="Tru
GridLines="None"
EmptyDataText="The Student may not have been enrolled for the 2008-2009 LI Courses.">
<AlternatingRowStyle BackColor="White" HorizontalAlign="Left" Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/plus_sign.png"
<span class="header"><%#Eval("CO
</asp:Panel>
<asp:Panel ID="pnlOrders" runat="server" Style="margin-left: 20px; margin-right: 20px;" HorizontalAlign="Left">
<asp:GridView AutoGenerateColumns="False
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True"
EnableModelValidation="Tru
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%-- <%# Container.DataItemIndex + 1 %> --%>
</ItemTemplate>
<ItemStyle CssClass="rownum" />
<FooterTemplate>
<%#Eval("finalpntspossible
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="213px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="93px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
</div>
</asp:Panel>
<asp:CollapsiblePanelExten
CollapseControlID="pnlCust
ExpandedImage="~/minus_sig
</asp:CollapsiblePanelExte
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="pacybergradeshea
Height="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FINALGRADE" HeaderText="Final Grade"
FooterText="Total Points">
<HeaderStyle CssClass="pacybergradeshea
HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<HeaderStyle BackColor="#026FA7" Font-Bold="True" ForeColor="White" Height="20px" HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Left" Height="20px" />
<RowStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" Height="20px" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" Height="20px" HorizontalAlign="Left" />
</asp:GridView>
can you share a screenshot of what you are seeing with your above code.....
ASKER
Ok, I have attached a screenshot showing that the Total Points value is 1000 and it's displaying beside the Assignment Title value and I have a BoundField Footer Text = "Final Grade" and would like the 1000 value to display next to the footer instead of displaying as a column.
data.gif
data.gif
ok just for test try this to see what I told earlier...
1: add OnRowDataBound="gvOrders_R owDataBoun d" to your gvOrders:
<asp:GridView AutoGenerateColumns="False " CssClass="grid" ID="gvOrders"
runat="server" GridLines="None" EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True" EnableModelValidation="Tru e" ForeColor="#333333" Width="400px"
OnRowDataBound="gvOrders_R owDataBoun d">
2: Add this to your code-behind:
protected void gvOrders_RowDataBound(obje ct sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = "1000";
}
}
Note: Though I am not clear exactly where you want that 1000 to appear corresponding to your figure.
1: add OnRowDataBound="gvOrders_R
<asp:GridView AutoGenerateColumns="False
runat="server" GridLines="None" EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True" EnableModelValidation="Tru
OnRowDataBound="gvOrders_R
2: Add this to your code-behind:
protected void gvOrders_RowDataBound(obje
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = "1000";
}
}
Note: Though I am not clear exactly where you want that 1000 to appear corresponding to your figure.
ASKER
Ok,
1.) I Added OnRowDataBound and it worked.
2.) The code behind worked as well
>> Note: Though I am not clear exactly where you want that 1000 to appear corresponding to your figure.
I need to display the value 1000 next to the Name of the Footer labeled "Final Grade". Right now the 1000 value is located at the very bottom of the first column of the GridView.
Also, I will need to add another value other than the one we are working with now. Now, how can i remove the actually hard coded value of 1000 and replace that with the actually value from the DB?
1.) I Added OnRowDataBound and it worked.
2.) The code behind worked as well
>> Note: Though I am not clear exactly where you want that 1000 to appear corresponding to your figure.
I need to display the value 1000 next to the Name of the Footer labeled "Final Grade". Right now the 1000 value is located at the very bottom of the first column of the GridView.
Also, I will need to add another value other than the one we are working with now. Now, how can i remove the actually hard coded value of 1000 and replace that with the actually value from the DB?
Try to modify the code-behind like below:
int fpPossible= 0;
protected void gvOrders_RowDataBound(obje ct sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
{
DataRowView drv = (DataRowView)e.Row.DataIte m;
fpPossible= (Decimal)drv["finalpntspos sible"];
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = fpPossible.ToString();
}
}
2: Adjust the gvOrders databinding code you provided in your comment#28570257 like below:
try
{
conn.Open();
DataTable dt = new DataTable();
SqlDataReader reader = cmd.ExecuteReader();
dt.Load(reader);
GridView gvOrders = e.Row.FindControl("gvOrder s") as GridView;
gvOrders.DataSource = dt;
gvOrders.DataBind();
}
3: Remove this code from your Markup:
<asp:TemplateField>
<ItemTemplate>
<%-- <%# Container.DataItemIndex + 1 %> --%>
</ItemTemplate>
<ItemStyle CssClass="rownum" />
<FooterTemplate>
<%#Eval("finalpntspossible ")%>
</FooterTemplate>
</asp:TemplateField>
-->I need to display the value 1000 next to the Name of the Footer labeled "Final Grade". Right now the 1000 value is located at the very bottom of the first column of the GridView.
Do you mean "Final Points" ?
you can adjust the cell Index in the code statement: e.Row.Cells[2].Text = fpPossible.ToString();
int fpPossible= 0;
protected void gvOrders_RowDataBound(obje
{
if (e.Row.RowType == DataControlRowType.DataRow
{
DataRowView drv = (DataRowView)e.Row.DataIte
fpPossible= (Decimal)drv["finalpntspos
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = fpPossible.ToString();
}
}
2: Adjust the gvOrders databinding code you provided in your comment#28570257 like below:
try
{
conn.Open();
DataTable dt = new DataTable();
SqlDataReader reader = cmd.ExecuteReader();
dt.Load(reader);
GridView gvOrders = e.Row.FindControl("gvOrder
gvOrders.DataSource = dt;
gvOrders.DataBind();
}
3: Remove this code from your Markup:
<asp:TemplateField>
<ItemTemplate>
<%-- <%# Container.DataItemIndex + 1 %> --%>
</ItemTemplate>
<ItemStyle CssClass="rownum" />
<FooterTemplate>
<%#Eval("finalpntspossible
</FooterTemplate>
</asp:TemplateField>
-->I need to display the value 1000 next to the Name of the Footer labeled "Final Grade". Right now the 1000 value is located at the very bottom of the first column of the GridView.
Do you mean "Final Points" ?
you can adjust the cell Index in the code statement: e.Row.Cells[2].Text = fpPossible.ToString();
ASKER
Ok, that worked out great....
How can I add another field below Final Grades with the value beside it?
How can I add another field below Final Grades with the value beside it?
ASKER
Ok, I was able to modify the code below to include the other value that I need but it displays the values side be side rather than up and down. Also, it does not display the Footer names beside the values.
protected void gvOrders_RowDataBound(obje ct sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
{
DataRowView drv = (DataRowView)e.Row.DataIte m;
fpPossible = (int)drv["FINALPNTSPOSSIBL E"];
fpEarned = (decimal)drv["FINALPNTSEAR NED"];
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
}
protected void gvOrders_RowDataBound(obje
{
if (e.Row.RowType == DataControlRowType.DataRow
{
DataRowView drv = (DataRowView)e.Row.DataIte
fpPossible = (int)drv["FINALPNTSPOSSIBL
fpEarned = (decimal)drv["FINALPNTSEAR
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
}
I am not understanding where and exactly how you want the footer to appear.
You can add FooterTemplate to the desired column e.g.
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>< br />
<asp:Label ID="Label2" runat="server" Text="Label"></Label>
</FooterTemplate>
Then in code-behind you can set those label text:
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl1 = (Label)e.Row.Cells[6].Find Control("L abel1");
lbl1.Text = "Points Possible";
Label lbl2 = (Label)e.Row.Cells[6].Find Control("L abel2");
lbl2.Text = "Points Earned";
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
Note: The above code is just a blind-shot because I really don't understand how you want to display.
You can add FooterTemplate to the desired column e.g.
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><
<asp:Label ID="Label2" runat="server" Text="Label"></Label>
</FooterTemplate>
Then in code-behind you can set those label text:
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl1 = (Label)e.Row.Cells[6].Find
lbl1.Text = "Points Possible";
Label lbl2 = (Label)e.Row.Cells[6].Find
lbl2.Text = "Points Earned";
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
Note: The above code is just a blind-shot because I really don't understand how you want to display.
ASKER
Ok, The Label controls are above each other which is what I needed, it would be nice if they would follow under the second column but if that's just a formating issue then I can probally figure it out. The only other problem is that I receive the following error when running the code.
ERROR CODE:
Specified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: index
ERROR CODE:
Specified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: indexSpecified argument was out of the range of valid values. Parameter name: index
ASKER
Ok, I made the following corrections and the code will return and return both values and labels but they do not line up with each other. I'm going to attach another screenshot.
NEW CODE:
protected void gvOrders_RowDataBound(obje ct sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
{
DataRowView drv = (DataRowView)e.Row.DataIte m;
fpPossible = (int)drv["FINALPNTSPOSSIBL E"];
fpEarned = (decimal)drv["FINALPNTSEAR NED"];
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl1 = (Label)e.Row.Cells[1].Find Control("L abel1");
lbl1.Text = "Points Possible";
Label lbl2 = (Label)e.Row.Cells[2].Find Control("L abel2");
lbl2.Text = "Points Earned";
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
}
data1.gif
NEW CODE:
protected void gvOrders_RowDataBound(obje
{
if (e.Row.RowType == DataControlRowType.DataRow
{
DataRowView drv = (DataRowView)e.Row.DataIte
fpPossible = (int)drv["FINALPNTSPOSSIBL
fpEarned = (decimal)drv["FINALPNTSEAR
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl1 = (Label)e.Row.Cells[1].Find
lbl1.Text = "Points Possible";
Label lbl2 = (Label)e.Row.Cells[2].Find
lbl2.Text = "Points Earned";
e.Row.Cells[1].Text = fpPossible.ToString();
e.Row.Cells[2].Text = fpEarned.ToString();
}
}
data1.gif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes!!! That is exactly what I needed. Is there anyway that I can format them such as making the values look like this below? It appears that both Label controls and the returned values are in one column, it would be nice to somehow stack the labels in one column and then display the values in the next column.
Points Possible: 1000
Points Earned: 686.00
Right now them look like the following below.
Points
Possible:
1000
Points
Earned:
686.00
Points Possible: 1000
Points Earned: 686.00
Right now them look like the following below.
Points
Possible:
1000
Points
Earned:
686.00
you might want to set the width of the column or may be move your FooterTemplate into second column i.e. the Assignment Title column instead.
e.g.:
e.g.:
<asp:TemplateField> <ItemTemplate>
<%#Eval("ASSIGNTITLE")%>
</ItemTemplate>
<FooterTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </FooterTemplate>
</asp:TemplateField>
ASKER
Not sure what you mean by 'move your FooterTemplate into second column'.
I have a width column for the assignment field but that doesn't seem to make the difference.
I have a width column for the assignment field but that doesn't seem to make the difference.
did you try my last code?
can you share the latest ..just gvOrders markup?
can you share the latest ..just gvOrders markup?
ASKER
I wasn't sure where I had to add that at. Below is teh gvOrder Markup.
<asp:GridView AutoGenerateColumns="False " CssClass="grid" ID="gvOrders"
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True"
EnableModelValidation="Tru e" ForeColor="#333333" Width="500px" OnRowDataBound="gvOrders_R owDataBoun d">
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%-- <%# container.dataitemindex + 1 %> --%>
</ItemTemplate>
<ItemStyle cssclass="rownum" />
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>< br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="300px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="80px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="80px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
<asp:GridView AutoGenerateColumns="False
runat="server" GridLines="None"
EnableViewState="False" CellPadding="4" HorizontalAlign="Left" ShowFooter="True"
EnableModelValidation="Tru
<FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#F0F0F0" ForeColor="#5A5A5A" HorizontalAlign="Center" />
<RowStyle CssClass="row" Height="20px" BackColor="#F0F0F0"
ForeColor="#5A5A5A" />
<AlternatingRowStyle CssClass="altrow" HorizontalAlign="Left" Height="20px"
BackColor="White"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%-- <%# container.dataitemindex + 1 %> --%>
</ItemTemplate>
<ItemStyle cssclass="rownum" />
<FooterTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Assignment" DataField="ASSIGNTITLE">
<HeaderStyle HorizontalAlign="Left" Width="300px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Possible" DataField="PNTSPOSSIBLE">
<HeaderStyle HorizontalAlign="Left" Width="80px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Pts. Earned" DataField="PNTSEARNED">
<HeaderStyle HorizontalAlign="Left" Width="80px"
CssClass="gvOrdersHeader" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
1:Removed First templated Column.
2: Changed "Assignment" BoundField to TemplateField and moved FooterTemplate inside it.
Check the attached file:
New-Text-Document.txt
2: Changed "Assignment" BoundField to TemplateField and moved FooterTemplate inside it.
Check the attached file:
New-Text-Document.txt
ASKER
Thank you VERY MUCH for all your help!!! I can't thank you enough for helping me all the way through. Keep up the GREAT work that you do!!!!
http://aspalliance.com/782_CodeSnip_How_to_Display_Sum_Total_in_the_Footer_of_the_GridView_Control