Click here to Skip to main content
15,922,512 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Install Setup from the Web Browser. Pin
RichardGrimmer16-Jun-06 5:27
RichardGrimmer16-Jun-06 5:27 
QuestionError on uploaded website, fine on the local system [modified] Pin
Sangeetha .v15-Jun-06 20:30
Sangeetha .v15-Jun-06 20:30 
AnswerRe: Error on uploaded website, fine on the local system Pin
Paddy Boyd15-Jun-06 23:50
Paddy Boyd15-Jun-06 23:50 
QuestionMail Error Pin
kirthikirthi15-Jun-06 20:04
kirthikirthi15-Jun-06 20:04 
QuestionReading Contents of a Word/Excel File. Pin
deepaks315-Jun-06 19:16
deepaks315-Jun-06 19:16 
QuestionInsert from GridView to DetailsView record Pin
kmeyer15-Jun-06 19:15
kmeyer15-Jun-06 19:15 
AnswerRe: Insert from GridView to DetailsView record Pin
minhpc_bk17-Jun-06 20:48
minhpc_bk17-Jun-06 20:48 
GeneralRe: Insert from GridView to DetailsView record Pin
kmeyer19-Jun-06 0:42
kmeyer19-Jun-06 0:42 
Thankyou for the reply, it would seem from the number of posts on various ASP.NET forums I am not alone. I am not alone, I will explore the RowDataBound event as a means to capture the values in the GridView (CustomerID & Name)

I thought this was going to be easy, hooking up a Gridview and DetailsView for some standard Master/Detail data entry.

For anyone reading this post if you can recommend a good book that focuses on C# ASP.NET database front ends I would appreciate knowing its name. I have already purchased 3 books reviewed on the Microsoft site, one is over 1000 pages only find very little on hooking up these two controls in a real world examples.

I have both forms linked and working well when details data exists. I also have the DetailsView defaulting to Insert by using the following useful code snippet I found on another post, when there is no detail record.


protected void SqlDataSource2_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.AffectedRows < 1)
{
DetailsView1.ChangeMode(DetailsViewMode.Insert);
}
}

Its at this point I want to populate the CustomerId & Name values from the selected Master record into the empty DetailsView record which is on a different page.
Many smaller examples show both controls on the same page.

I have tried the following from a post by Polita Paulas the creator of the GridView, DetailsView and FormView controls.

"The best way to do this is to handle the DataBound event, check if the Mode is Insert, then set the text in the controls to the default properties.
For instance:
protected void DetailsView1_DataBound(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.Insert)
{
((TextBox)DetailsView1.Rows[0].Cells[1].Controls[0]).Text = "Default";
}
}
"
I have tried this with test data and cannot seem to get it to work, the Cell always remains empty, no errors are thrown.

A number of posts suggest you must use template fields, like the following post, I could not get this to work either.

protected void DetailsView1_DataBound(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.Insert)
{
TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1");
tb.Text = DateTime.Now.ToShortDateString();
}
}


I am thinking this must be so easy and thats why my posts on this site and another go vertually unanswered or its too hard and no one really knows.
GeneralRe: Insert from GridView to DetailsView record Pin
minhpc_bk19-Jun-06 16:40
minhpc_bk19-Jun-06 16:40 
GeneralRe: Insert from GridView to DetailsView record Pin
kmeyer19-Jun-06 20:35
kmeyer19-Jun-06 20:35 
QuestionEmail validation Pin
Uma Kameswari15-Jun-06 18:48
Uma Kameswari15-Jun-06 18:48 
AnswerRe: Email validation Pin
Suamal15-Jun-06 19:10
Suamal15-Jun-06 19:10 
GeneralRe: Email validation Pin
Uma Kameswari15-Jun-06 19:52
Uma Kameswari15-Jun-06 19:52 
AnswerRe: Email validation Pin
psid2315-Jun-06 19:22
psid2315-Jun-06 19:22 
GeneralRe: Email validation Pin
Uma Kameswari15-Jun-06 20:01
Uma Kameswari15-Jun-06 20:01 
Question.net Pin
surshbabuk15-Jun-06 18:19
surshbabuk15-Jun-06 18:19 
AnswerRe: .net Pin
surshbabuk15-Jun-06 18:20
surshbabuk15-Jun-06 18:20 
GeneralRe: .net Pin
surshbabuk15-Jun-06 18:22
surshbabuk15-Jun-06 18:22 
AnswerRe: .net Pin
surshbabuk15-Jun-06 18:21
surshbabuk15-Jun-06 18:21 
GeneralRe: .net Pin
surshbabuk15-Jun-06 18:22
surshbabuk15-Jun-06 18:22 
AnswerRe: .net Pin
minhpc_bk15-Jun-06 23:43
minhpc_bk15-Jun-06 23:43 
QuestionEmail SMTP settings. [modified] Pin
Kenzy8615-Jun-06 16:52
Kenzy8615-Jun-06 16:52 
QuestionRandom password generation Pin
pitturamakrishna15-Jun-06 11:25
pitturamakrishna15-Jun-06 11:25 
AnswerRe: Random password generation Pin
Elina Blank15-Jun-06 12:23
sitebuilderElina Blank15-Jun-06 12:23 
AnswerRe: Random password generation Pin
Mircea Grelus15-Jun-06 12:51
Mircea Grelus15-Jun-06 12:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.