How to customize Footer in GridView. [Resolved]

Posted by Vasanthmvp under ASP.NET on 8/25/2012 | Points: 10 | Views : 11659 | Status : [Member] | Replies : 5
I have a GridView in which i want to customize my footer as:

Im firing a method to include the text in to the footer using

<Columns>
<asp:TemplateField>
<FooterTemplate>
<%# WriteUrl() %>
</FooterTemplate>
</asp:TemplateField>
</Columns>

However if im using the OnRowDataBound i am facing the same problem.
The text is getting displayed but the gridview is expanding and the whole text is getting displayed with in the one cell itself.

How to set total footer as one cell. or specify colspan for the footer.

Response/Suggestions in detail are appreciated.

ThankYou,

Awesome Coding !! :)


Responses

Posted by: Vasanthmvp on: 8/27/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
The issue is solved through the below code. Thanks to my friend Siva.

Suppose, if the column count is m.
Include Onrowdatabound method with gridviewroweventarguments e.
Under which,

I took a literal control lit to display my message in the footer.

int m = e.Row.Cells.Count;
for (int i = m - 1; i >= 1; i--)
{
e.Row.Cells.RemoveAt(i); // which removes the other cells leaving one cell in the row
}
e.Row.Cells[0].ColumnSpan = m; // now i'm expanding my row cell with colspan=num of columns
e.Row.Cells[0].Controls.Add(lit);



Regards,

Awesome Coding !! :)

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 8/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hello, I think below articles can help you much:
http://www.ezzylearning.com/tutorial.aspx?tid=1676759
http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/displaying-summary-information-in-the-gridview-s-footer-vb


Never give up! Smile to the world!
http://excelcsharp.blog.com/

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 8/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Megan,
Thanks for the reply.
Im afraid to say the referenced links were not giving me the complete solution.

Actually, my problem is to render the summary info/something in to the Gridview footer, with not in to each cells(i.e each column level) like aggregate displayed in the above links. But, to set the whole row as one cell.

If im taking the colspan,then extra cells are getting added and gridview is expanding.

Please, can you suggest me any further.

Thanks a ton..!!,

Awesome Coding !! :)

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 8/27/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
JavaScript for Footer

<script language="javascript" type="text/javascript">
function getScrollBottom(p_oElem)
{
return p_oElem.scrollHeight - p_oElem.scrollTop - p_oElem.clientHeight;
}
</script>
Code behind bind the data source to gridview
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New DataTable
dt.Columns.Add("C1")
dt.Columns.Add("C2")
Dim drRow As DataRow
For i As Integer = 0 To 10
drRow = dt.NewRow
drRow(0) = "C1" & i
drRow(1) = "C2" & i
dt.Rows.Add(drRow)
Next
Me.gvDemo.DataSource = dt
Me.gvDemo.DataBind()
End Sub

with in a panel write your grid view and we can use div also



Thanks to fenglinzh for his article

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 8/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Sarath,
Thanks for your reply.

I think,the info in the above response is basically about displaying a gridview. I was asking about the footer customization.

Anyway, i got the solution.

Thanks,

Awesome Coding !! :)

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response