473,396 Members | 2,081 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,396 software developers and data experts.

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 2365
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_ItemCreated(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == 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 SelectedDatechanged event to update the selected date to the
certain textbox in the InsertItemtemplate. e.g;

==========detailsview's template field========
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Description") %>'></asp:TextBox><br />
<asp:Calendar ID="cld1" runat="server"
OnSelectionChanged="cld1_SelectionChanged"></asp:Calendar>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Description") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
===================

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

TextBox txt = cld1.NamingContainer.FindControl("TextBox1") as
TextBox;

txt.Text = cld1.SelectedDate.ToString("yyyy-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
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...
2
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...
12
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...
1
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...
4
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...
3
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...
4
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....
0
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...
1
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...
5
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:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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,...

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.