How to get value of field in one DataView into an Select statement for another DataView?

I have a DataView, called DataView1, that is showing the data from a table called INFO.  A DetailsView is attached to this DataView.
When I click the Select link on a record for DataView1, I want the value of a certain field of DataView one to be put into the Select query of DataView2. 

The reason being is this.
DataView1 contains the data for my INFO table.
DataView2 contains the data for my FILES table.
INFO can have many FILES.
Files can only have one INFO. 

So when I click the Select link on a record on my DataView1(INFO table), I want only the files associated with the record to show up in DataView2(FILES table.)

Sorry if I am confusing.
How would I do this?
0
jettman26
7/17/2005 5:36:43 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
637 Views

Similar Articles

[PageSpeed] 41

Hello.
well, i think that you can do that by using the new data source controls and parameters.
--
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
0
Luis
7/17/2005 8:27:46 PM

Thanks for the reply.
Do you have any examples?

Here is my code that I have so far.  Notice my select statement for DataView2.  Where the question marks are is where I don't know what to put.

 

<asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="True" runat="server"

DataSourceID="SqlDataSource1" DataKeyNames="info_id"

AutoGenerateColumns="False" Width="500px" SelectedIndex="0" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged" OnRowDeleted="GridView1_RowDeleted" OnSorted="GridView1_Sorted" >

<Columns>

<asp:CommandField ShowSelectButton="true" ShowDeleteButton="true" />

<asp:BoundField DataField="info_id" HeaderText="info_id" ReadOnly="True" SortExpression="info_id" />

<asp:BoundField DataField="class_name" HeaderText="class_name" ReadOnly="True" SortExpression="class_name" />

<asp:BoundField DataField="info_date" HeaderText="info_date" SortExpression="info_date" />

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=LAPTOP;Initial Catalog=classes;Persist Security Info=True;User ID=jettman26;Password=jettmanou812"

SelectCommand="SELECT * FROM [info]"

DeleteCommand="DELETE FROM [info] WHERE [info_id] = @original_info_id" ProviderName="System.Data.SqlClient">

</asp:SqlDataSource>

</td>

<td valign="top">

<asp:DetailsView AutoGenerateRows="False" DataKeyNames="info_id" DataSourceID="SqlDataSource3"

HeaderText="Info Details" ID="DetailsView1" runat="server" Width="700px" OnItemUpdated="DetailsView1_ItemUpdated" OnItemInserted="DetailsView1_ItemInserted" >

<Fields>

<asp:BoundField DataField="info_id" HeaderText="info_id" ReadOnly="True" SortExpression="info_id" />

<asp:TemplateField HeaderText="class_name" SortExpression="class_name">

<EditItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"

DataTextField="class_name" DataValueField="class_name" SelectedValue='<%# Bind("class_name") %>'>

</asp:DropDownList>

</EditItemTemplate>

<InsertItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"

DataTextField="class_name" DataValueField="class_name" SelectedValue='<%# Bind("class_name") %>'>

</asp:DropDownList>

</InsertItemTemplate>

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Bind("class_name") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="info_date" SortExpression="info_date">

<EditItemTemplate>

<asp:Calendar ID="Calendar1" runat="server" VisibleDate='<%# Bind("info_date") %>' SelectedDate='<%# Bind("info_date") %>'>

</asp:Calendar>

</EditItemTemplate>

<InsertItemTemplate>

<asp:Calendar ID="Calendar1" runat="server" >

</asp:Calendar>

</InsertItemTemplate>

<ItemTemplate>

<asp:Label ID="Label2" runat="server" Text='<%# Bind("info_date") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="notes" HeaderText="notes" SortExpression="notes" />

<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />

</Fields>

</asp:DetailsView>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:classesConnectionString %>"

SelectCommand="SELECT DISTINCT [class_name] FROM [classes]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="Data Source=LAPTOP;Initial Catalog=classes;Persist Security Info=True;User ID=jettman26;Password=jettmanou812"

SelectCommand="SELECT [info_id], [class_name], [info_date], [notes] FROM [info] WHERE ([info_id] = @info_id)"

UpdateCommand="UPDATE [info] SET [class_name] = @class_name, [info_date] = @info_date, [notes] = @notes WHERE [info_id] = @original_info_id"

InsertCommand="INSERT INTO [info] ([class_name], [info_date], [notes]) VALUES (@class_name, @info_date, @notes)" ProviderName="System.Data.SqlClient">

<SelectParameters>

<asp:ControlParameter ControlID="GridView1" Name="info_id" PropertyName="SelectedValue"

Type="String" />

</SelectParameters>

<UpdateParameters>

<asp:Parameter Name="info_date" Type="String" />

<asp:Parameter Name="notes" Type="String" />

<asp:Parameter Name="original_info_id" Type="String" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="class_name" Type="String" />

<asp:Parameter Name="info_date" Type="String" />

<asp:Parameter Name="notes" Type="String" />

</InsertParameters>

</asp:SqlDataSource>

</td>

</tr>

<tr>

<td valign="top">

<asp:GridView ID="GridView2" AllowSorting="True" AllowPaging="True" runat="server"

DataSourceID="SqlDataSource4" DataKeyNames="file_id"

AutoGenerateColumns="False" Width="500px" SelectedIndex="0" >

<Columns>

<asp:ButtonField Text="Download" CommandName="Download"/>

<asp:CommandField ShowDeleteButton="True" />

<asp:BoundField DataField="file_name" HeaderText="file_name" ReadOnly="True" SortExpression="file_name" />

<asp:BoundField DataField="file_size" HeaderText="file_size" SortExpression="file_size" />

<asp:BoundField DataField="file_path" HeaderText="file_path" SortExpression="file_path" />

<asp:BoundField DataField="upload_date" HeaderText="upload_date" SortExpression="upload_date" />

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="Data Source=LAPTOP;Initial Catalog=classes;Persist Security Info=True;User ID=jettman26;Password=jettmanou812"

SelectCommand="SELECT [Files.file_id], [Files.info_id], [Files.file_name], [Files.file_path] FROM [files] INNER JOIN [Info] ON [Files.info_id] = [Info.info_id] AND [Files.info_id] = [Info.info_id] WHERE [Files.info_id] = ???????????????

DeleteCommand="DELETE FROM [files] WHERE [file_id] = @original_file_id" ProviderName="System.Data.SqlClient">

</asp:SqlDataSource>

</td>

</tr>

0
jettman26
7/17/2005 8:37:11 PM
 Luis Abreu wrote:
Hello.
well, i think that you can do that by using the new data source controls and parameters.


Luis Abreu,
I figured it out.  You pointed me in the right direction.  Thanks!
0
jettman26
7/17/2005 11:11:53 PM
Hi,
Detailview or Gridview cannot contain LIST controls in its EditItemTemplate,
Mabey you can search the reason in this forums.

0
dida
9/13/2005 12:16:38 AM
Reply:

Similar Artilces:

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

How to select value from another select statement?
Table People (column - Id,Count) Table Skill (column - Id,Skill) first I want to select people who have Skill in "2" select a.Id  from people a, Skill b where a.Id = b.Id and b.skill=2 Result 1 :  Id --- aa bb cc dd ee   and then I want to select which people have a Min(count) from Result 1 how to write a query? combine 2 query into 1 query? thank you   P.S. I'am talking about MSSQL 2000 thank you very much The relationship would be clearer if Table People (column - Id,Count) Table Skill (column - Id,Skill) BecameTable Peop...

want to call one c#.net function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

Select the value from a field of one table and place it into another table.
Using VB.NET, VS2005, SQL Server 2000. In a Windows Form, how could I provide a means for a user to select the value from a field of one table (a primary key value) and place it into another table (as a foreign key value)? The goal is to "assign" a person from one table to a location in another table by placing the person's primary key value into the location's foreign key field via an easy to use "selection" mechanism like a DataGridView or something.Thanks in advance for any help or examples.David  this is an ASP.Net forum - - you might want to check out: http://forums.microsof...

How can I get the value of one single column from a DataSet/DataView?
I have a DataSet or DataView that contains a bunch of info. I can filter down to one row using .RowFilter on the DataView. I want to simply populate a label with the string value of column "A" for example. This should be easy, but I am struggling with it. Any suggestions?--[_]-[_]--AGENT_SMITH Well a dataview is going to give a Row of data.... It's up to you to just bind or fetch the single column that you are looking for.... Here is an example of some code that I use to fetch from the ASP.Cache object a readonly dataview.... and use it as the datasource for ...

Setting control values from one user control to another
I have two user controls on a page.  Control 1 is view. Control2 is search.  User selects value on Control2 and I want to update Control1(View).  I cannot find syntax to change values on Control1 from Control2.  The following is function on Control1 that is called from Control2 after pageInit and load on Control1.  I have tried many many ways to findControl but all fail. 'Function on Control1 called from Control2 after Control1 PageInit/load:         Public Function loadForm...

Trying to pass values from one control to another control
I have 2 controls on my page. CaseList and Email Reviwer. CaseList contain a datagrid that when the button (5th column) is clicked 2 values should be passed to the email revier control. In the email Reviwer Control I have declared: I have: public void sendCaseIdCatId(int catid,int caseid) { ViewState["EmailReviewerCategoryId"] = catid; ViewState["EmailReviewerCaseid"] = caseid; } in my EmailReviwer control   I tried: //Display the email reviewer panel EmailCaseReviewer.Visible=true; string strcatid = e.Item.Cells[1].Text.ToString(); string strcaseid = e.Item.Cells[0].Text.T...

TFDTable: Control which fields gets selected (avoid SELECT * FROM ...)
Is there a way to limit/control the generated select clause for TFDTable? We want/need to select only the fields which are defined in the Fileds or FieldDefs Collection (no SELECT * FROM). We could use TFDQuery but it seems no to support Live Window Mode, is that right? Regards Robert > Is there a way to limit/control the generated select clause for TFDTable? > We want/need to select only the fields which are defined in the Fileds or FieldDefs Collection (no SELECT * FROM). There is no way. You should use TFDQuery. > We could use TFDQuery but it seems no to support L...

getting at fields in dataviews
dv1.Item(i).Row.Item(10) = "" dv1.Item(i).Row.Item(11) = "" dv1.Item(i).Row.Item(12) = "" Instead of this, i want something like this: dv1.Item(i).Row.find("a") = "" dv1.Item(i).Row.find("b")="" dv1.Item(i).Row.find("c")="" where a,b,c or field( aka column) names I can also do a similiar process in myDataSet (where dv1 comes from) Reason being, these fields may not always be in this order if the SPROC changes, but the fields t...

pressing button in one control to populate fields in another control
Does anyone know how to press a button in one calls a fucntion to query a database for a record and then populate fields forms in another control?Thanks  In Advance Just make the button's click even call DataBind().  So if you are using a datagrid it would be grid.datasource = blah; grid.DataBind(); Eric RamseurRainbow Portal 2.0 AdminDownload Rainbow 2.0!!Rainbow Code Rainbow Portal CommunityC# 2005 Group...

Pass value from one User Control to another User Control
I have tried to pass value from one user control to another user control. Because of Page Auto Postback, Contrls are load before page is loaded. So I get the value in 2nd UC after one more post back operation. I have visited many suggessions but I cant solve this. Is anyone can help me to solve this. Thank U mfhossain@gmail.com Muhmmad Fakhrul HossainEmail: mfhossain@gmail.comPhone: +88 01715 111512Web: http://www.mfhossain.info You'd have to do that through the parent probably in it's Page_Load event handler.   userControl1.publicProperty = userControl2.publicProperty;  ...

How to pass control values from one ascx user-control to another???
Our site is set up using a primary default aspx page that is used as the "base page" for everything. On this page, we dynmaically place various user controls at run-time. This gives us a functionality similar to using frames where the outer-frame actually just sits there while various webfiles are loaded inside of it. Works great except for one thing... trying to figure out the best way to pass control names/values accross user controls. When the same usercontrol is posting back to itself this is a non issue. So far most of our functionality has worked well using the local...

change format of one control based on value of another control
Hi, I am very new to ASP.net and need some help with an odd requirement.  We use Visual Web Developer for all our work and have built our corporate intranet around it.  On our home page we have a hyperlink to our IT departments status page (traffic light system), we want to change the colour of the hyperlink text to be the same as the most serious traffic light on the other page (may be even flash the text for "red" issues)? Our IT department directly edit the traffic light network status page themselves, via a text editor, so the hyperlink on the home page needs to pic...

Passing value from one control to another and inserting that value in a table
Hey all, sorry if the subject is confusing or has already been covered, but I have (obviously) a problem (at least one).This is using:Visual Studio 2005ASP.NET 2.0SQL Server 2005 ExpressVisual Basic I'm building a CRM system for my company and have run into a snag when attempting to add new customer records for a given client. The first thing that any CSR (or admin) must do upon accessing the CRM system is choose which client's customers they are actually working with (we have multiple clients and are ultimately responsible for providing customer service to the clients' end ...

Web resources about - How to get value of field in one DataView into an Select statement for another DataView? - asp.net.presentation-controls

User:Jimbo Wales/Statement of principles - Wikipedia, the free encyclopedia
As we move forward with software and social changes, I think it is imperative that I state clearly and forcefully my views on openness and the ...

Category:Articles containing potentially dated statements from June 2006 - Wikipedia, the free encyclopedia ...
This is an administration category . It is used for administration of the Wikipedia project and is not part of the encyclopedia. It contains ...

Peyton Manning Issues Statement Denying Doping Allegations - Bleacher Report
Denver Broncos quarterback Peyton Manning has issued a statement strongly denying that he received human growth hormone from an anti-aging clinic ...

Charlie Sly recants statements about Peyton Manning - Business Insider Deutschland
Peyton Manning and other pro athletes have been named in an explosive Al Jazeera investigation into doping in pro sports.

Chicago police statement on double fatal police shooting - Chicago Tribune
Get unlimited digital access to chicagotribune.com. Try it today for ONLY $0.99. Chicago Tribune Chicago police statement on West Garfield Park ...

Super Mario Bros World 1-1 Gets Remade to Make Bold Statement About Accessibility
To be honest, I’m not totally sure what to think about this little video , but its heart seems to be in the right place. The creators of the ...

China firm loses 5 years of financial statements
China Animal Healthcare has lost five years of financial statements midway through a forensic audit ordered by regulators.

Does Draymond feel Warriors have chance to make statement vs Cavs?
... Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Does Draymond feel Warriors have chance to make statement ...

UK Gov’t Issues Statement On Possibly Banning Trump From Britain
UK Gov’t Issues Statement On Possibly Banning Trump From Britain

Peyton Manning Responds To Forthcoming HGH Allegations In ESPN Statement
Despite the Al Jazeera documentary alleging his ties to a doping ring having not yet aired, Peyton Manning spoke to ESPN this morning to deny ...

Resources last updated: 1/3/2016 10:58:35 AM