473,394 Members | 1,737 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,394 software developers and data experts.

DataGrid + BoundColumn + UpdateCommand

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 :)

Nov 19 '05 #1
1 1863
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
el********@hotmail.com

"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 :)

Nov 19 '05 #2

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

Similar topics

0
by: Leona Smyth | last post by:
I am trying to update data directly in a datagrid using the UpdateCommand. However when I click the update button in my datagrid nothing seems to happen. I keep going round in circles and can't...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
8
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)...
3
by: CJ Smit | last post by:
Hi Guys I have a datagrid that are databound at runtime and columns are added automatically to it from the dataset. OnEdit Command renders all fields as editable, my problem is I need to specify...
3
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...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
2
by: Derek Vincent | last post by:
What must I do to overcome a problem with my dates becoming formatted as "2/22/2525 12:00:00 AM" in the datagrid? I want to handle all dates as short string of format "2/22/2525." Otherwise when I...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
23
by: tanya2001 | last post by:
hi all.. I am trying to update my datagrid in my webform...but its not getting updated..though in the database it removing the <null> and inserting a blank field....its not taking the input which m...
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: 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
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?
0
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.