473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1894
Hi Niki,

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

<asp:datagrid id="datagrid" runat="server">
<Columns>
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate"
CancelText="Can cel" EditText="Edit" ></asp:EditCommand Column>
<asp:BoundColum n Visible="False" DataField="ID" ></asp:BoundColumn >
<asp:BoundColum n DataField="Fiel dName" ReadOnly="True" HeaderText="Fil ed
Name"></asp:BoundColumn >
<asp:BoundColum n DataField="Edid _FieldName" HeaderText="Fil ed
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********@hotm ail.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
2744
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 seem to work out whats wrong. I've included the html code and the info from the code behind page. Could someone please please help me work out where i;ve went wrong. HTML <asp:datagrid id="DataGrid2" style="Z-INDEX: 101; LEFT:
3
4889
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 the best method? Do you have a sample of how to do this?
8
1715
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) AdminGrid.EditItemIndex = -1 BindData()
3
1489
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 in some way which columns are not editable, I have the columns I would like to lock for editing, but how do I tell the datagrid this ? My columns are dynamically added to the grid at runtime, because the dataset might be different everytime Any...
3
2222
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 make the changes and click Update, it reverts back to the old value. I'm stumped! I've also checked the db table and it is infact not updating. I'm attempting to follow and example right out of ASP.NET Unleashed but not having much luck. Any...
2
1617
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. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : namespace OakTree.data {
2
5151
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 run the update routine SQL (set start_date = "2/22/2525 12:00:00 AM") does not work while short string (set date = '2/22/2525') does work. See update routine below: Private Sub MarketingDataGrid_UpdateCommand(ByVal source As Object, ByVal e...
9
2734
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 code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
23
1962
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 typing...can sombody plz help me out in this..i need help urgently I am posting the code in vb.net for the webform as well as html Protected Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As...
0
10639
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.