PC Review


Reply
Thread Tools Rate Thread

Data List Insert new problem

 
 
Ed Dror
Guest
Posts: n/a
 
      3rd Mar 2008
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 colors)

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 this
item.

Now when you click on new button the GN_ID field become empty and I want to
preserve that GN_ID
I don't want the user to enter the GN_ID every time they enter a new color
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



 
Reply With Quote
 
 
 
 
Steven Cheng
Guest
Posts: n/a
 
      4th Mar 2008
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 me
to 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 try
providing some ideas depend on them.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up 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/subscripti...t/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
>From: "Ed Dror" <(E-Mail Removed)>
>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

colors)
>
>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

this
>item.
>
>Now when you click on new button the GN_ID field become empty and I want

to
>preserve that GN_ID
>I don't want the user to enter the GN_ID every time they enter a new color
>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
>
>
>
>


 
Reply With Quote
 
Ed Dror
Guest
Posts: n/a
 
      4th Mar 2008
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 = @GN_Id)
where the @GN_Id is the drop down control GN_ID

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 the
GN_ID)
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"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 me
> to 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 try
> providing some ideas depend on them.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up 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/subscripti...t/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
> --------------------
>>From: "Ed Dror" <(E-Mail Removed)>
>>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

> colors)
>>
>>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

> this
>>item.
>>
>>Now when you click on new button the GN_ID field become empty and I want

> to
>>preserve that GN_ID
>>I don't want the user to enter the GN_ID every time they enter a new color
>>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
>>
>>
>>
>>

>



 
Reply With Quote
 
Steven Cheng
Guest
Posts: n/a
 
      5th Mar 2008
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" <(E-Mail Removed)>
>References: <#$p5#(E-Mail Removed)>

<(E-Mail Removed)>
>Subject: Re: Data List Insert new problem
>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 =

@GN_Id)
>where the @GN_Id is the drop down control GN_ID
>
>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

the
>GN_ID)
>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"" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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

me
>> to 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

try
>> providing some ideas depend on them.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>>
>> ==================================================
>>
>> Get notification to my posts through email? Please refer to
>>

http://msdn.microsoft.com/subscripti...ult.aspx#notif
>> ications.
>>
>>
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent

issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each

follow
>> up 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/subscripti...t/default.aspx.
>>
>> ==================================================
>>
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>>
>> --------------------
>>>From: "Ed Dror" <(E-Mail Removed)>
>>>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

>> colors)
>>>
>>>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

>> this
>>>item.
>>>
>>>Now when you click on new button the GN_ID field become empty and I want

>> to
>>>preserve that GN_ID
>>>I don't want the user to enter the GN_ID every time they enter a new

color
>>>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
>>>
>>>
>>>
>>>

>>

>
>
>


 
Reply With Quote
 
Ed Dror
Guest
Posts: n/a
 
      5th Mar 2008
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"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)>
>>References: <#$p5#(E-Mail Removed)>

> <(E-Mail Removed)>
>>Subject: Re: Data List Insert new problem
>>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 =

> @GN_Id)
>>where the @GN_Id is the drop down control GN_ID
>>
>>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

> the
>>GN_ID)
>>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"" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>> 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

> me
>>> to 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

> try
>>> providing some ideas depend on them.
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>>
>>> ==================================================
>>>
>>> Get notification to my posts through email? Please refer to
>>>

> http://msdn.microsoft.com/subscripti...ult.aspx#notif
>>> ications.
>>>
>>>
>>>
>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent

> issues
>>> where an initial response from the community or a Microsoft Support
>>> Engineer within 1 business day is acceptable. Please note that each

> follow
>>> up 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/subscripti...t/default.aspx.
>>>
>>> ==================================================
>>>
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>>
>>>
>>> --------------------
>>>>From: "Ed Dror" <(E-Mail Removed)>
>>>>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
>>> colors)
>>>>
>>>>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
>>> this
>>>>item.
>>>>
>>>>Now when you click on new button the GN_ID field become empty and I want
>>> to
>>>>preserve that GN_ID
>>>>I don't want the user to enter the GN_ID every time they enter a new

> color
>>>>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
>>>>
>>>>
>>>>
>>>>
>>>

>>
>>
>>

>



 
Reply With Quote
 
Steven Cheng
Guest
Posts: n/a
 
      6th Mar 2008
Hi Ed,

Thanks for your reply.

so your current solution is using GridView's SelectedIndexChanged event to
synchronize the Textbox, I think that's also a good idea.

Thanks for sharing this with us.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: "Ed Dror" <(E-Mail Removed)>
>Subject: Re: Data List Insert new problem
>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"" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)>
>>>References: <#$p5#(E-Mail Removed)>

>> <(E-Mail Removed)>
>>>Subject: Re: Data List Insert new problem
>>>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 =

>> @GN_Id)
>>>where the @GN_Id is the drop down control GN_ID
>>>
>>>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

>> the
>>>GN_ID)
>>>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"" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed)...
>>>> 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

>> me
>>>> to 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

>> try
>>>> providing some ideas depend on them.
>>>>
>>>> Sincerely,
>>>>
>>>> Steven Cheng
>>>>
>>>> Microsoft MSDN Online Support Lead
>>>>
>>>>
>>>>
>>>> ==================================================
>>>>
>>>> Get notification to my posts through email? Please refer to
>>>>

>>

http://msdn.microsoft.com/subscripti...ult.aspx#notif
>>>> ications.
>>>>
>>>>
>>>>
>>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent

>> issues
>>>> where an initial response from the community or a Microsoft Support
>>>> Engineer within 1 business day is acceptable. Please note that each

>> follow
>>>> up 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/subscripti...t/default.aspx.
>>>>
>>>> ==================================================
>>>>
>>>>
>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>> rights.
>>>>
>>>>
>>>>
>>>> --------------------
>>>>>From: "Ed Dror" <(E-Mail Removed)>
>>>>>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
>>>> colors)
>>>>>
>>>>>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
>>>> this
>>>>>item.
>>>>>
>>>>>Now when you click on new button the GN_ID field become empty and I

want
>>>> to
>>>>>preserve that GN_ID
>>>>>I don't want the user to enter the GN_ID every time they enter a new

>> color
>>>>>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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>>

>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to call data from a one worksheet list and insert into anothe creed Microsoft Excel Programming 1 23rd Sep 2009 07:41 PM
How do I insert alternating blank rows in a list of data? =?Utf-8?B?Y3VyaW91c2NhdA==?= Microsoft Excel Worksheet Functions 10 18th Sep 2006 11:09 PM
Problem with Insert data in sql =?Utf-8?B?U2VyYWZpbiBDYWJhbGxlcm8=?= Microsoft VB .NET 1 15th Jun 2006 07:09 AM
how do I insert 4 rows in between each value in a list of data =?Utf-8?B?Q2FsbHVt?= Microsoft Excel Misc 2 13th Apr 2006 03:40 PM
How do I find data from a list (or table) and insert it in a row? =?Utf-8?B?Qm9iZ29sZnM1Ng==?= Microsoft Excel Misc 1 3rd Feb 2005 12:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 AM.