Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   button column (http://www.velocityreviews.com/forums/t761909-button-column.html)

Chris 04-22-2005 05:58 PM

button column
 
I need to add a button column to my datagrid. I need to be able to do this
at runtime. I can not have the tag <columns></columns> in my aspx page.

This is where I am at

Private Function CreateProjectDataSource(ByVal projectds As DataSet, ByVal
dg As DataGrid) As ICollection
Try
Dim btn As System.Web.UI.WebControls.Button
Dim dt As DataTable
Dim dr As DataRow
dt = New DataTable
Dim i As Integer
dg.AllowSorting = True
btn = New System.Web.UI.WebControls.Button
btn.ID = "btn" & i
btn.Visible = True
btn.Text = "Edit"
btn.CommandName = "btn" & i

<!-- i am stuck with this
dt.columns.add(new buttomcolumn())<!--- cant do that.. how do i do this



dt.Columns.Add(New DataColumn("Project Name", GetType(String)))
dt.Columns.Add(New DataColumn("Project Category", GetType(String)))
dt.Columns.Add(New DataColumn("Customer", GetType(String)))
dt.Columns.Add(New DataColumn("Budget Hours", GetType(Double)))
'Make some rows and put some sample data in
For i = 0 To projectds.Tables(0).Rows.Count - 1
With projectds.Tables(0).Rows(i)
dr = dt.NewRow()
'dr(0).cells.add(btn)
dr(0) = btn
dr(1) = .Item("Project Name")
dr(2) = .Item("Project Category")
dr(3) = .Item("Customer")
dr(4) = .Item("Budget Hours")
'add the row to the datatable
dt.Rows.Add(dr)
End With
Next
'return a DataView to the DataTable
CreateProjectDataSource = New DataView(dt)
Catch ex As Exception
End Try
End Function

THanks

Chris



Brock Allen 04-25-2005 05:52 PM

Re: button column
 
It's ButtonColumn, not ButtomColumn. Other than the typo, it should be possible
to add a new column dynamically.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> I need to add a button column to my datagrid. I need to be able to do
> this at runtime. I can not have the tag <columns></columns> in my aspx
> page.
>
> This is where I am at
>
> Private Function CreateProjectDataSource(ByVal projectds As DataSet,
> ByVal
> dg As DataGrid) As ICollection
> Try
> Dim btn As System.Web.UI.WebControls.Button
> Dim dt As DataTable
> Dim dr As DataRow
> dt = New DataTable
> Dim i As Integer
> dg.AllowSorting = True
> btn = New System.Web.UI.WebControls.Button
> btn.ID = "btn" & i
> btn.Visible = True
> btn.Text = "Edit"
> btn.CommandName = "btn" & i
> <!-- i am stuck with this
> dt.columns.add(new buttomcolumn())<!--- cant do that.. how do i do
> this
> dt.Columns.Add(New DataColumn("Project Name", GetType(String)))
> dt.Columns.Add(New DataColumn("Project Category", GetType(String)))
> dt.Columns.Add(New DataColumn("Customer", GetType(String)))
> dt.Columns.Add(New DataColumn("Budget Hours", GetType(Double)))
> 'Make some rows and put some sample data in
> For i = 0 To projectds.Tables(0).Rows.Count - 1
> With projectds.Tables(0).Rows(i)
> dr = dt.NewRow()
> 'dr(0).cells.add(btn)
> dr(0) = btn
> dr(1) = .Item("Project Name")
> dr(2) = .Item("Project Category")
> dr(3) = .Item("Customer")
> dr(4) = .Item("Budget Hours")
> 'add the row to the datatable
> dt.Rows.Add(dr)
> End With
> Next
> 'return a DataView to the DataTable
> CreateProjectDataSource = New DataView(dt)
> Catch ex As Exception
> End Try
> End Function
> THanks
>
> Chris
>






All times are GMT. The time now is 02:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.