What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 62552 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > How to customize Footer in GridView. ...
Vasanthmvp

How to customize Footer in GridView.

Replies: 5 | Posted by: Vasanthmvp on 8/25/2012 | Category: ASP.NET Forums | Views: 1003 | Status: [Member] | Points: 10  


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 !! :)


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Megan00
Megan00  
Posted on: 8/26/2012 11:12:10 PM
Level: Starter | Status: [Member] | Points: 25

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

Vasanthmvp
Vasanthmvp  
Posted on: 8/27/2012 12:22:36 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Saratvaddilli
Saratvaddilli  
Posted on: 8/27/2012 1:01:11 AM
Level: Bronze | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Vasanthmvp
Vasanthmvp  
Posted on: 8/27/2012 4:31:34 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Vasanthmvp
Vasanthmvp  
Posted on: 8/27/2012 4:37:08 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 11:19:17 AM