473,382 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help 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
Nov 21 '05 #1
0 764

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
2
by: Anita C | last post by:
Hi, How do I associate or map a specific column in a datatable to a particular element present in an xml document - to read into a datatable as well as write from the datatable to the xml element?...
8
by: pei_world | last post by:
Hi, there; I have a problem with my datagrid control. I declared it in one of my form, set with DataGridTalbeStyle as well, and when I click on button, I would like to retrive Data from Database...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
1
by: Mark | last post by:
Hello, I have a need to add a button column to a datagtrid, below is my code and although it does not produce an error, it also does not work, any help? I'm hoping that I can capture the button...
2
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it...
4
by: W. Watson | last post by:
I have about a 1600 line Pythron program I'd like to make some simple mods to, but have really just a nodding acquaintance with Python and Tkinter. I know quite a few languages, including C++....
1
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...
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.