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 2 1258
Chris, it would help seeing an example of what you're trying to do
(describing the business problem, not the code), but for one why are you
trying to add the button to the datatable and not the datagrid? Why can't you
use <columns>? Are you forced to autogenerate the columns for some reason? Is
the button exactly the same for each column, or is it on/off depending on the
data that's in that row?
Bill
"Chris" wrote: 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
Chris, it would help seeing an example of what you're trying to do
(describing the business problem, not the code), but for one why are you
trying to add the button to the datatable and not the datagrid? Why can't you
use <columns>? Are you forced to autogenerate the columns for some reason? Is
the button exactly the same for each column, or is it on/off depending on the
data that's in that row?
Bill
"Chris" wrote: 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: crystalattice |
last post by:
I'm creating a shelve interface using Tkinter. I have a button that
allows the user to modify an existing entry; when the button is
clicked, a new TopLevel window appears with Entry boxes holding...
|
by: Forumtroll |
last post by:
I have a Web User Control that parses an XML file and renders a Form
based on the XML.
The problem is that I create a button on the bottom of the form that
will fire off a subscribeable event, but...
|
by: Forumtroll |
last post by:
I have a Web User Control that parses an XML file and renders a Form
based on the XML.
The problem is that I create a button on the bottom of the form that
will fire off a subscribeable event, but...
|
by: JRough |
last post by:
Hi,
I have a page with a form that is included into a php page. It has
some php variables which are headers based on the user choices. In
the form I will send some mysql data columns but right...
|
by: harichinna |
last post by:
Hi to all,
My name is hari, iam trying to delete the column value of spread sheet using c sharp,
iam trying to get the value and compare, when comparing it showing some errors, can any one help...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |