Re: Data List Insert new problem
- From: "Ed Dror" <edd@xxxxxxxxxxxxxxxx>
- Date: Wed, 5 Mar 2008 11:09:45 -0800
Steven,
I try this solution but it dosen't seems to work so I changed the dropdown
to GridView with the folowing code
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles GridView1.SelectedIndexChanged
txtGNID.Text = Me.GridView1.SelectedRow.Cells(1).Text
End Sub
Then I created a form with submit botton that call Stored Proc
usp_InsertColor and it works
Thanks,
Ed Dror
""Steven Cheng"" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:hvHOiLnfIHA.1500@xxxxxxxxxxxxxxxxxxxxxxxxx
Thanks for your reply Ed,
So for the control display the color lists you selected from database, is
it a DataList or DetailsView control? It would be hard for me to give you
some detailed code snippet without knowing the exact control you used,
that's why I ask you give me some aspx template or snippet that will make
it much easier to understand(database schema is not that important here
since what we want to do is just get a value which is databound to display
in another control and the control structure is the most important thing
here).
I assume that your insert template( those controls that help you insert a
new record of Color) contains a Textbox to let user input Color ID, then,
you can just use the following code in Textbox's "preRender" event to
assign it the value from DropDownlist:
<<<<<<<<<<<<<<<<<<
Protected Sub TextBox1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.PreRender
Dim ddl As DropDownList = Page.Form.FindControl("DropDownList1")
Dim txt As TextBox = sender
txt.Text = ddl.SelectedValue
End Sub
#again, here I assume that the DropDownlist is at top level of the page
and
I use Form.FindControl to locate it. This may vary depend on the control
hierarchy
Also, as you mentioned, you may also do the updating in DropDownList's
selected index change event to refresh the TextBox's value.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Ed Dror" <edd@xxxxxxxxxxxxxxxx><xb0g8KafIHA.6844@xxxxxxxxxxxxxxxxxxxxxx>
References: <#$p5#EXfIHA.6136@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: Data List Insert new problem@GN_Id)
Date: Tue, 4 Mar 2008 13:28:02 -0800
Steven,
Catalog_GN table
GN_ID - PK
Brand
Model
this table point to Dropdown List GN_ID Data value field
and Data text field point to (Brand + Model)
Color
ColorID PK
ColorName
GN_ID FK reference to Catalog_GN table
One to Many relationship
This point to detail view control (select * from color where GN_Id =
where the @GN_Id is the drop down control GN_IDthe
Now when I'm selecting let say GN_ID 35 in the the drop down
The DetailsView control show ColorID = 40 with 3 colors (that belong to
GN_ID)me
The GN_ID show 35
is very simple and work fine
Now when you add a new Color the Details view control open a blank fields
(except for the ColorID)
My question is there any way to preserve the GN_ID (35) when you click on
New color?
Like on index change me.DetailsView1.FindControl("GN_ID") =
me.Dropdownlist1.Text
or somthing like that to save the user entry that can cause mistake
When you click on edit for example nothing change
Thanks,
Ed Dror
""Steven Cheng"" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:xb0g8KafIHA.6844@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Ed,
Based on my understanding, you have the following controls on the page
to
display some one-many datas:
** a dropdown that display the main records
** a datalist that display detailed info of main record(selected in
dropdown)
And your question here is how to make the textbox contains initial
value(of
the PK of current main record) when user perform inserting(for child
colors), correct?
I'd suggest you poste a simplified aspx page template and some brief
description of how the controls will work together at runtime so as for
tryto understand it more clearly. So far, I think the init value for
textbox(for inserting) can be got from two place:
1. Is the dropdownlist (since datalist's displaying record also come
from
dropdownlist selection)
2. Is the DataList
If this is true, there are also multiple means:
1. Add Event handler for the textbox(for inserting) and it will query
the
current selected dropdownlist item and retrieve the PK info from it
2. You can store the info into DataList during databinding and then let
the
Textbox retrieve the value from the control(maybe a html hidden field)
later (like in #1)
If this is not quite clear, you can give me some html snippet and I'll
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notifproviding some ideas depend on them.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
issuesications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
followwhere an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
colorup response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Ed Dror" <edd@xxxxxxxxxxxxxxxx>colors)
Subject: Data List Insert new problem
Date: Mon, 3 Mar 2008 13:00:35 -0800
Hi there,
I'm using Wisual Studio 2005 Pro with SQL server 2005 Dev on XP SP2
I have two tables
Generic Item table (GN_ID) PK
Color Table (Color_ID) PK and GN_ID FK
very simple one to many relationship (one Generic Item can have many
this
I created a Dropdown list that select items from Generic Item table
Then I created a Datalist control based on the GN_ID in the dropdown
list
with Edit and new Button
Until here everything was very simple and work just fine
when I pick a Generic Item the data list show all color that belong to
item.to
Now when you click on new button the GN_ID field become empty and I want
preserve that GN_ID
I don't want the user to enter the GN_ID every time they enter a new
based on GN_ID from the Generic Table
Is there any way to read the GN_ID from cache?
Or create a trigger? if so how
Thanks,
Ed Dror
.
- Follow-Ups:
- Re: Data List Insert new problem
- From: "Steven Cheng"
- Re: Data List Insert new problem
- References:
- Data List Insert new problem
- From: Ed Dror
- RE: Data List Insert new problem
- From: "Steven Cheng"
- Re: Data List Insert new problem
- From: Ed Dror
- Re: Data List Insert new problem
- From: "Steven Cheng"
- Data List Insert new problem
- Prev by Date: Re: Repeater woes
- Next by Date: Re: How to call function from one aspx page from another
- Previous by thread: Re: Data List Insert new problem
- Next by thread: Re: Data List Insert new problem
- Index(es):