Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid + BoundColumn + UpdateCommand

Reply
Thread Tools

DataGrid + BoundColumn + UpdateCommand

 
 
niki
Guest
Posts: n/a
 
      06-17-2005
Hello.
I have a problem with custom columns inside the datagrid.
I've set up a datagrid that populates from a database; I can edit the
datagrid values and update the db, so that's ok.
(btw, it's not as easy as the book claims...)

Now I'd like to format some columns, say date values, and what's more,
I'd like to make some columns not visible and some read-only.
I thought BoundColumn could be the solution, but as I create columns
this way and invoke the updatecommand event, the datagrid has no more
columns.
Inside the updatecommand event, the datagrid has just 1 column, I guess
it's the button one...

I've search this ng for some advice, but I couldn't understand how it
can be done.

Can you help me?

Thanks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      06-17-2005
Hi Niki,

You can use BoundCloumns and set Visible, ReadOnly properties for the
BoundCloumns like follows.:

<asp:datagrid id="datagrid" runat="server">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn Visible="False" DataField="ID" ></asp:BoundColumn>
<asp:BoundColumn DataField="FieldName" ReadOnly="True" HeaderText="Filed
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="Edid_FieldName" HeaderText="Filed
Name"></asp:BoundColumn>
....

</Columns>
</asp:datagrid>

Updatecommand event is trggered by clicking Update button. You can get data
by e.Item.Cells[col_index].Text.

HTH

Elton Wang




"niki" wrote:


> Hello.
> I have a problem with custom columns inside the datagrid.
> I've set up a datagrid that populates from a database; I can edit the
> datagrid values and update the db, so that's ok.
> (btw, it's not as easy as the book claims...)
>
> Now I'd like to format some columns, say date values, and what's more,
> I'd like to make some columns not visible and some read-only.
> I thought BoundColumn could be the solution, but as I create columns
> this way and invoke the updatecommand event, the datagrid has no more
> columns.
> Inside the updatecommand event, the datagrid has just 1 column, I guess
> it's the button one...
>
> I've search this ng for some advice, but I couldn't understand how it
> can be done.
>
> Can you help me?
>
> Thanks
>
>

 
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
Boundcolumn or TemplateField when to use Boundcolumn and when TemplateField ???? mesut ASP .Net 0 06-29-2007 10:17 AM
DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand srathin ASP .Net Web Controls 2 04-10-2005 11:07 PM
DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand srathin ASP .Net Datagrid Control 0 04-09-2005 03:05 AM
REPOST: Column [blah] is readonly on Datagrid UpdateCommand event Learning SQL Server ASP .Net 2 08-07-2003 01:10 PM
update problem in DataGrid's UpdateCommand method dawn ASP .Net 1 07-28-2003 02:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57