473,834 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DetailsView

I need to customize the DetailsView New record (insert) so that it gets the
maximum value of ROWID and adds 1, places that value in the textbox and
makes it read only.

Also, I have a field called "DATEEVENT" . I would like to place a calendar
control there instead of the textbox that is shown.

Thanks for any help.
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com


Mar 21 '06 #1
1 2422
Hi Vbnetdev,

Welcome to the ASPNET newsgroup.

As for the two detailsview questions you mentioned, I think both of them
require additioal customization on the columns/fields. For such scenario,
it's better to use TemplateFields instead of the default BoundField. In vs
2005's design-view, the DetailsView's smartTag wizard provide the UI to let
us convert a certain boundfield to a templatefield. After that, we can do
some customization on the template of the certain column/field. e.g: we can
add some addtional controls into the template (like calendar...).

For your two questions, the first one (set the max rowID to the textbox in
insert template) can be done by registering the DetailsView' ItemCreated
event, and add some code to manually query the max rowID allowed from the
database and assign the value to the insert template's certain textbox. e.g:

protected void DetailsView1_It emCreated(objec t sender, EventArgs e)
{
if (DetailsView1.C urrentMode == DetailsViewMode .Insert)
{
//find the certain control and assign the value queried from db
to it
}
}
For the second question, we can put a calendar in the InsertTemplate, and
use its SelectedDatecha nged event to update the selected date to the
certain textbox in the InsertItemtempl ate. e.g;

==========detai lsview's template field========
<asp:TemplateFi eld HeaderText="Des cription" SortExpression= "Descriptio n">
<EditItemTempla te>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Descripti on") %>'></asp:TextBox><br />
<asp:Calendar ID="cld1" runat="server"
OnSelectionChan ged="cld1_Selec tionChanged"></asp:Calendar>
</EditItemTemplat e>
<InsertItemTemp late>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Descripti on") %>'></asp:TextBox>
</InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Descripti on") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:CommandFie ld ShowEditButton= "True"
ShowInsertButto n="True" />
</Fields>
</asp:DetailsView >
=============== ====

=======calendar 's event handler======== ===
protected void cld1_SelectionC hanged(object sender, EventArgs e)
{
Calendar cld1 = sender as Calendar;

TextBox txt = cld1.NamingCont ainer.FindContr ol("TextBox1") as
TextBox;

txt.Text = cld1.SelectedDa te.ToString("yy yy-MM-dd");
}
=============== ===========

Hope this helps.

regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Mar 22 '06 #2

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

Similar topics

1
10074
by: Shawn Wildermuth | last post by:
I have a *single* SqlDataSource that loads up a single result set that I show in a GridView. In the GridView, i've added a "Select" button and handling the SelectedItem event. I also have a DetailsView (though FormView has this same issue) where I want to be able to set the current item to bind to from the DataSource. All the examples I've seen use two data sources and on every *select* they do another round-trip to the Database (which...
2
3630
by: Andrew Robinson | last post by:
Is there any way to accomplish two way data binding in a Details View with a DataSet or DataTable as the DataSource. All I want is to get an updated DataSet or DataTable back from the DetailsView and then handle my updating manually. -Andrew
12
8709
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
1
4442
by: sck10 | last post by:
Hello, I am trying to change a value when a user goes into edit mode on a DetailsView control. I am trying to use the following, but can not figure out how to get to the bound field ("MyBoundField") to set its new value. Any help with this would be appreciated. Sub EmployeeDetailView_ModeChanged(ByVal sender As Object, ByVal e As EventArgs) Select Case CustomerDetailView.CurrentMode
4
16074
by: Frits van Soldt | last post by:
Hello, I hope somebody can help me with this! I have 2 listboxes in the edititemtemplate of a detailsview. In the databound event of the detailsview I would like to fill the listboxes programmatically (not through databinding). If I use detailsview.findcontrol(controlname) then an empty object is returned. How can I address these controls? Thank you for your time.
3
4075
by: chrisn | last post by:
Hi, (Using ASP.Net 2.0) I have a wizard control inside a detailsview control. When I attempt to call the InsertItem method on the DetailsView I get an error "ObjectDataSource 'ObjectDataSource1' has no values to insert. Check that the 'values' dictionary contains values." I have found I can suppress the error by placing a hidden field inside
4
7721
by: Kjell Arne | last post by:
Hi! I have a detailsview control in a webpart with some templated fields on. I set the ValidationGroup property to som value on these fields to distinguish from other web parts on the page. However, I'm not able to set the same ValidationGroup on the submit controls on the detailsview. Those linkbuttons(update, insert) are auto generated now. 1. Is it possible to set ValidationGroup on the detailsview? 2. How would I go about...
0
2557
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the sample provided by Microsoft and other comminity sites. Most of the samples were using Databinding using a DesignTime "SqlDataSource" Control and assigning its ID to DataSourceID property of DetailsView. However, in all of my application we DO...
1
5032
by: needhelp1 | last post by:
I have gridview with a detailsview below. When I click on 'New' in brings up the DetailsView for inserting. When I click on 'Edit' in does not brink up the DetailsView. What am I doing wrong? I totally at a loss, please help. I don't know if I need to something to grdUserProfile_RowEditing. Thank you! This is some of my code behind: protected void grdUserProfile_RowEditing(object sender, GridViewEditEventArgs e) { } protected void...
5
3471
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration: default.aspx:
0
9644
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10509
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...
1
10547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10219
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...
1
7757
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
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
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
3
3081
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.