Hello
Today I had to build a DataGrid very dynamically
<asp:datagrid id="dgTAB" Runat="server" AutoGenerateColumns="False" OnEditCommand="TAB_Edit" OnCancelCommand="TAB_Cancel" OnUpdateCommand="TAB_Update" OnDeleteCommand="TAB_Delete"><Columns><asp:ButtonC olumn HeaderText="Delete" Text="Delete" CommandName="Delete" /><asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" /></Columns></asp:datagrid
This is quite a classical one. Then I add in the code behind
BoundColumn col = new BoundColumn ()
col.DataField = ...
col.HeaderText = ...
dgTAB.Columns.Add (col)
I have some of these, I don't know how many without querying my database, which is why I did it that way in the first place
I managed the Delete column very well with a DataKeyField, but I have problems with the Edit Column. By hitting 'Delete', my DataGrid line becomes a line of TextBox which is ok, but hitting 'Update' won't work as I can't access the textboxes' values. It seems that when I enter my TAB_Edit function, the Columns collection only has the two columns Delete & Edit, and not all the BoundColumns I added..
Any suggestions ? Thank
Karine 1 1570
(an error slipped through while writing the message...
Hello
Today I had to build a DataGrid very dynamically
<asp:datagrid id="dgTAB" Runat="server" AutoGenerateColumns="False" OnEditCommand="TAB_Edit" OnCancelCommand="TAB_Cancel" OnUpdateCommand="TAB_Update" OnDeleteCommand="TAB_Delete"><Columns><asp:ButtonC olumn HeaderText="Delete" Text="Delete" CommandName="Delete" /><asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" /></Columns></asp:datagrid
This is quite a classical one. Then I add in the code behind
BoundColumn col = new BoundColumn ()
col.DataField = ...
col.HeaderText = ...
dgTAB.Columns.Add (col)
I have some of these, I don't know how many without querying my database, which is why I did it that way in the first place
I managed the Delete column very well with a DataKeyField, but I have problems with the Edit Column. By hitting 'Edit' (and not 'Delete', my mistake in the first msg), my DataGrid line becomes a line of TextBox which is ok, but hitting 'Update' won't work as I can't access the textboxes' values. It seems that when I enter my TAB_Edit function, the Columns collection only has the two columns Delete & Edit, and not all the BoundColumns I added..
Any suggestions ? Thank
Karine This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lu |
last post by:
I have a page with datagrid (for viewing,
delete,edit,update) and text fields with button to add
info to database.
When user comes to page the datagrid selects info from
database, binds in...
|
by: Kathy Burke |
last post by:
Hi, I'm doing a fairly simple datagrid (copied it from one that works).
When I run the page, it gets and binds the datasource ok, but then I get
an unhandled app error at End Sub. I've found this...
|
by: Brent Burkart |
last post by:
My datagrid OnCancelCommand event is not firing.
HTML
OnCancelCommand="AdminGrid_Cancel"
'Code Behind
Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)...
|
by: John Spiegel |
last post by:
Hi all,
As usual, I have found a way to make the straightforward, textbook example
fail. I have a datagrid that supports editing. When I edit a row then fire
the update, the value that gets...
|
by: D. Shane Fowlkes |
last post by:
I have a Datagrid which in theory, should allow you to edit and update the
records. I've stripped my test page down so that it's only attempting to
update one field - "description". Yet when I...
|
by: Elton W |
last post by:
Hi Peter,
You use
DeleteButton.Attributes.Add("onclick", "return confirm
('Are you sure you want to delete?');");
in datagrid_ItemDataBound event to add confirmation for
delete button.
|
by: Joe |
last post by:
Hi,
I have form with datagrid. This is what my form tag looks like,
<form runat="server">
<asp:label runat="server" id="lblMessage" />
<asp:DataGrid runat="server" id="articleList"...
|
by: p.mc |
last post by:
Hi all,
I'm having major problems with a userControl which contains a datagrid.
My problem concerns data binding.
The Page_Load() procedure calls the DataBind procedure to bind the
datagrid...
|
by: tjc0ol |
last post by:
Hi guys,
Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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: 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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
| |