Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 datagrid

Author  Topic 

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-06 : 21:11:40
hi all!

how do i add buttons in my datagrid extraheader?This is my extraheader code:-

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgList.ItemCreated
If e.Item.ItemType = ListItemType.Header Then
Dim dgItem As DataGridItem
Dim dgCell As TableCell
dgItem = New DataGridItem(0, 0, ListItemType.Header)
dgCell = New TableCell
dgCell.ColumnSpan = 2
dgItem.Cells.Add(dgCell)
dgCell.Text = "List of Products"
dgList.Controls(0).Controls.AddAt(0, dgItem)
End If
End Sub


~~~Focus on problem, not solution~~~

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-06 : 21:28:18
it's done with;
 Dim btnRefresh As New Button
btnRefresh.Text = "Refresh"
dgCell.Controls.Add(btnRefresh)
btnRefresh.Width = ?
btnRefresh.Height = ?
AddHandler btnRefresh.Click, AddressOf btnRefresh_Click
dgList.Controls(0).Controls.AddAt(0, dgItem)

but,
1.how do i assign the width and height of the button? putting just number giving me error..
2.ive no idea why the paging also print below my extra header...



~~~Focus on problem, not solution~~~
Go to Top of Page

dfiala
Posting Yak Master

116 Posts

Posted - 2007-04-06 : 21:39:39
These properties take a value of the tyepe Unit

btnRefresh.Height = New Unit(30)
btnRefresh.Width = New Unit(60)

Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-06 : 22:59:36
hi dfiala,
thanks... yea.. it gave me that error type unit but i didnt know the coreect syntax.. thanks//
btw, how bout Q2? my datagrid paging appear below my extra header grid.. how to fix this?? thankss

~~~Focus on problem, not solution~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-07 : 00:38:04
below is my datagrid..
1.i wanted to add more than 1 button in my extra header, but only 1 button appear..
2.i ve no idea why the paging appear in the header. pliz help.. this is my code

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgList.ItemCreated
If e.Item.ItemType = ListItemType.Header Then
Dim dgItem As DataGridItem
Dim dgCell As TableCell
dgItem = New DataGridItem(0, 0, ListItemType.Header)
dgCell = New TableCell
dgCell.ColumnSpan = 2
dgItem.Cells.Add(dgCell)
dgCell.Text = "List of Products"
Dim btnRefresh As New Button
btnRefresh.Height = New Unit(20)
btnRefresh.Width = New Unit(40)
btnRefresh.Text = "Delete"
Dim btnUpdate As New Button
btnUpdate.Height = New Unit(20)
btnUpdate.Width = New Unit(40)
btnUpdate.Text = "Update"
dgCell.Controls.Add(btnRefresh)
AddHandler btnRefresh.Click, AddressOf btnRefresh_Click
dgList.Controls(0).Controls.AddAt(0, dgItem)
End If
End Sub


if this image too small here's the link :
http://picasaweb.google.com/maya.zakry/ScreenShots/photo#5050533591981982914




~~~Focus on problem, not solution~~~
Go to Top of Page

dfiala
Posting Yak Master

116 Posts

Posted - 2007-04-07 : 08:47:53
You need to add two buttons. You just create two buttons.
dgCell.Controls.Add(btnRefresh) 'You have this
dgCell.Controls.Add(btnUpdate) 'YOu don't have this

Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-07 : 22:54:59
hi dean..
yea.. how carelesss..
but how about the paging? did u notice my paging also appear on top of datagrid? why is this happen? anyway to do the interface in .aspx not in the codebehind? usually i did the datagrid interface in the .aspx, but this tutorial (i mean to create the extraheader) use codebehind to create button and all..
tq in advance and congrats of the MVP

~~~Focus on problem, not solution~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-30 : 00:14:49
hi again,
if i have btnRefresh in my added header, how would i call that button outside the DataGrid1_ItemCreated.. this wont work :-

Dim btnRefresh As Button
btnRefresh = CType(dgi.Cells(1).FindControl("btnEdit"), Button)

and declaring the DataGrid1_ItemCreated to public also did not help..

thanks in advance

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-06-04 : 21:15:41
hi.. to those who just read this topic, the question now are :-
1. how would i remove extra pager in the added header? it appear both when i turn the allow-paging ON


~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-06-06 : 01:32:02
hello.. am i invisible? HUWAAAAAAAAAAAA.. need to solve this asap.. uwaaa

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page
   

- Advertisement -