|
Hello,
Using the SqlDataSource object to declaratively bind data to a DataList which contains another DataList. Code is similar to:
<asp:DataList ID="parent">
<ItemTemplate>
<asp:DataList ID="child">
</asp:DataList>
<asp:SqlDataSource ID="childDataSource" SelectCommand="Select * FROM childTable WHERE parentId = ?" />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="parentDataSource" SelectCommand="Select * FROM parentTable" />
Basically my question is, how do I refer to the current parent datalist item in the child's datasource (what do I replace the ? with).
Sorry if this is not clear. Thanks in advance for your time.
|
|
|
|
|
Hi there,
In this case, you can define a select parameter for the child SqlDataSource control. If you are not familiar with the Parameter, you can read the document in MSDN:
Using Parameters with the SqlDataSource Control [^]
Basically, there are a couple of parameters which you can use like the generic Parameter or ControlParameter .
+ With the Paremeter, you cannot bind data from the parent datalist item to the DefaultValue property of the Parameter as the Parameter does not have the DataBinding event, so you should create an event handler for the Selecting event of the child SqlDataSource control, and populate the select parameter value in there.
+ With the ControlParameter, you can simply bind data from the parent datalist to a control like Label. If you don't want to display it in the datalist, you can set the Visible to false. Then you simply define a ControlParemeter for the child SqlDataSource control, and configure the ControlParameter to get the value from this Label control. The sample markup look like this:
<asp:DataList ID="parent">
<ItemTemplate>
<asp:Label ID="lblParentID" Text='<%# Eval("parentId")%>' />
<asp:DataList ID="child">
</asp:DataList>
<asp:SqlDataSource ID="childDataSource"
SelectCommand="Select * FROM childTable WHERE parentId = @parentId" >
<SelectParameters>
<asp:controlparameter name="parentId" controlid="lblParentID" propertyname="Text"/>
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="parentDataSource" SelectCommand="Select * FROM parentTable" />
|
|
|
|
|
This was my first thought, however...
Exception Details: System.InvalidOperationException: Could not find control 'lblInput' in ControlParameter 'InputId'.
The SelectParameter cannot find the label because it is within the DataList's ItemTemplate. I've also tried filling in the parameter on the Selecting event and that doesn't seem to work either.
-- modified at 9:20 Tuesday 2nd May, 2006
Edit:
For now I've solved the problem by setting the select command like so:
SelectCommand='<%# "SELECT * FROM childTable WHERE parentId = " + Eval("parentId").ToString() %>'
This'll do for now, was hoping there was something built in.
|
|
|
|
|
hi,
i have a TreeView component with its data bound to and XmlDataSource object. According to different users different xml strings are generated and bound to xmldatasource and also to treeview component.
when i first login as one user, treeview is shown correctly and the xml string. but when i close the ie, and start application and login again with another user, different (i see in the test div) xml is generated(normally), but when i bound it to treeview, treeview shows the past xml data(the one which i logged in first)
why?
thanks
|
|
|
|
|
Hi there,
Looks like the XML data is cached in the XmlDataSource control. Do you have the EnableCaching property set to false ?
|
|
|
|
|
thank you very much !! it worked.
|
|
|
|
|
When I needed to learn how to use the TreeView control in VS 2005, I went to the http://www.KYNOU.com website and searched using the criteria: "treeview". Why don't you go ahead and try it.
sfdsfsdf
|
|
|
|
|
i've set XmlDataSource's EnableCaching property to false, and it worked.
thanx
|
|
|
|
|
andy one who can talk german lang and help me whit ban system i wanne ban user from my windows server
i wanne have ban option for mac adress
hard disk id and cpu id and this thinks all pc information i have a voice chat system in bv script and asp help me ill pay for it thanx
hello world
|
|
|
|
|
You can't detect the mac address, hard disk id or cpu id from clients, unless you install a program in the client computer that sends this information to the server.
---
b { font-weight: normal; }
|
|
|
|
|
i have a cab the user must instal the cab to use my site
we can put the dll inside them when we can worke whit dll
right now i have a page where i can get ip and ban ip and kick the pc but the do format pc and came back so i need some think what dont change after format
hello world
|
|
|
|
|
Hello,
I have been waiting for answer to this question from last 2 days. I posted it in Sql Forum. But,I did not get answer. So, I am posting it here.
I have one ObjectDataSource which has a Select query that requires Parameter @CompanyId. CompanyId is Guid and I want to compare it with a bunch of GUID. Can i pass those Guid programatically???
my Query is like..
select a.companyId, b.startdate, b.....
from a,b
where a.companyId IN (@CompanyID)
|
|
|
|
|
DotNetDominator wrote: I have been waiting for answer to this question from last 2 days. I posted it in Sql Forum. But,I did not get answer.
There are many reasons you may not have received an answer. The bottom line is that this is a community site. People take their own time to answer questions. If you require an answer urgently then Microsoft Support can help for a small payment.
DotNetDominator wrote: So, I am posting it here.
Your question has nothing to do with ASP.NET so it is inappropriate for this forum.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Hi there,
You can define a select parameter for the ObjectDataSource control, then create a handler for the Selecting event of the datasource control. In the handler, you can pass a list of the CompanyID values to the input parameter collection.
Using Parameters with the ObjectDataSource Control [^]
|
|
|
|
|
Hi,
Mr.Mackay,
I Do appreciate the help provided by people by taking time for it from their busy schedule. But, I did mean to blaim any one for not getting reply. It's just that I was desperate to have answer because I've to finish this project in 10 days. I'll surely consider your suggestion of joining Microsoft support for urgent answer. But, As long as I am a student, I can not afford it. I joined this forum because, I found it very authentic and rich with knowledge. Anyway...I'll take care in selection of forum before i post. Thank you.
Hi minhpc_bk,
I am very very thankful for the reply.. Just what i wanted... It is running fine now... earlier i was thinking to pass parameter as http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm
but it requires stored procedure.. Thank you very much for solution.
|
|
|
|
|
If i am having 10 tables in my dataset.xsd,is it is necessary to have 10 different Data Adapter in my project or single Data Adapter is enough.
|
|
|
|
|
Hi there,
Actually, you can also use a single DataAdapter object to fill one or more datatables in the dataset.
|
|
|
|
|
I have made some web parts in vs2005 and now on run time i make some changes by using drag drop operation. Can anyone tell me how and where those changes made at runtime are saved in DB of SQLExpress. I got that those are saved in APP_DATA folder of application in personalization tables. but there those were in form of image dat so i could not get them. So any views about that?
Its urgent so please reply fast.
|
|
|
|
|
Hi there,
By default, the ASP.NET uses the the SQL Express database file in the App_Data to store the personalization data. If this file is not available, the ASP.NET will automatically add it to the application. As you may already know that the central class in the Web Parts is the WebPartManager which responsible for persisting the personalization data. The WebPartManager serializes and persists the properties of the web part control which are marked with the Personalizable attribute. In the AspnetDb, there 3 tables which are used for the personalization, they are aspnet_Paths, aspnet_PersonalizationAllUser, aspnet_PersonalizationPerUser. You also see that the personalizable property is saved as binary data because the property is serialized with the ObjectStateFormatter object. You can read more about this in MSDN:
Web Parts Personalization Overview [^]
|
|
|
|
|
Hi!
There is a website that contains free online tutorials. I used the search criteria: "web part" and I found a tutorial that walks through a process that might be the answer of your question.
Why don't you go ahead and try it: http://www.KYNOU.com
|
|
|
|
|
Hi,
I read the artical
http://www.codeproject.com/useritems/Excel_Connectivity.asp
Its nice and i need some change.
I want to read an excel stream from the Web Page and
has to capture rows and column data from that stream
without saving the stream as a file in the physical
disk.
In this artical, we have specified a file name in the
connection string.
Anybody can clarify this ?
Thanks,
Murthy.
|
|
|
|
|
If you have comments or questions about a specific article, you should post them on the article's forum. Scroll to the bottom of any article and you'll find its forum.
|
|
|
|
|
Hello,
I am running an ASP.NET application that works perfectly on the localhost but when I try to load on the browser from the server, I have the following error:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".
I did all mentioned in the details section but am still getting same error.. can some one help? I have worked on this for days...
|
|
|
|
|
|
Hello,
I will check this documentation...
Thanks for you reply though....
Commickey
|
|
|
|