Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid : dynamic BoundColumn & OnUpdateCommand

Reply
Thread Tools

DataGrid : dynamic BoundColumn & OnUpdateCommand

 
 
=?Utf-8?B?S2FyaW5lIFByb290?=
Guest
Posts: n/a
 
      01-27-2004
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2FyaW5lIFByb290?=
Guest
Posts: n/a
 
      01-27-2004
(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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Newbie Problem]DataGrid OnUpdateCommand "InvalidCastException" problem DC ASP .Net 2 08-07-2007 01:39 PM
Boundcolumn or TemplateField when to use Boundcolumn and when TemplateField ???? mesut ASP .Net 0 06-29-2007 10:17 AM
datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures Jim in Arizona ASP .Net Datagrid Control 0 12-29-2006 10:31 PM
datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures Jim in Arizona ASP .Net 0 12-28-2006 10:22 PM
DataGrid: OnUpdateCommand - getting the updated values Dan ASP .Net Datagrid Control 0 08-18-2005 10:16 AM



Advertisments