How do I nest a datalist inside a gridview column?  ASP.NET 2005

Posted on 2008-02-03
Medium Priority
Last Modified: 2013-11-26
I have a working gridview.
I added this to the aspx fpage or a datalist1 control:
                        <asp:DataList ID="DataList1" runat="server" Style="z-index: 101; left: 0px; position: absolute;top: 0px">
                    <ItemStyle Width="500px" />

But now I'm stuck on how to get it to work right.  My gridview column 1 displays RecordIDs.  In column 2, I want a datalist that will do a "Select Name, Address from DBO.Workshops Where RecordID = <the recordID in Gridview column One>

Any help would be greatly appreciated!
Question by:arthurh88
  • 2
LVL 10

Expert Comment

ID: 20812482
On rowdatabound of gridview, you need to find the datalist and based on the record id fetch the records and bind the results with the datalist.

let me know if further assitance is needed

Author Comment

ID: 20812498
im not sure the code to do that.  can you please post an example of code ?  I can fetch the record ID from the gridview just fine, but how do I tell the nested datalist?
LVL 10

Expert Comment

ID: 20812507
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       if (e.Row.RowType == DataControlRowType.DataRow)
           DataList oDataList = (DataList)e.Row.FindControl"'Datalist1");
           oDataList1.DataSource = DataSet1; //or any other data source

check this if this helps.
LVL 12

Accepted Solution

Munawar Hussain earned 2000 total points
ID: 20812509

here is same thing done.

working code is also attached..
only one thing you need to change is DataList repeat property to vertical instead of horizontal

if you have any question let me know.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question