15,918,889 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Basit Elahi (Top 17 by date)
Basit Elahi
11-Aug-15 7:08am
View
That was not my intent at all. i just figured out my question was wrong. Anyhow thanks for your consideration
Basit Elahi
17-Sep-14 7:06am
View
may b. how can i check that? and is it make any difference?
Basit Elahi
17-Sep-14 6:31am
View
yes i can access my site on my server pc with both name and ip address. but cannot access on another machine with both of these in absence of internet
Basit Elahi
17-Sep-14 5:46am
View
if i write http://192.168.0.55/site/default.aspx on my server pc browser, it opens (when my server ip is 192.168.0.55). but same thing does not open on other machines in same network
Basit Elahi
10-Aug-14 15:08pm
View
right now x axis is displaying 10 dates instead of displaying my processed dates with interval of 14 between the dates
Basit Elahi
28-Apr-14 3:13am
View
my project was developed in 4.0 but where i am deploying it, that pc has framework 3.5
Basit Elahi
3-Feb-14 15:01pm
View
i know it is not same and for the same reason i have mentioned at the end that both of these are used to populate drop down list. Now i have improved the question. Please check out the latest one
Basit Elahi
30-Jan-14 7:19am
View
thanks prasadavunuri. i took idea from this and have solved my problem.
Basit Elahi
29-Jan-14 8:23am
View
yes it is working fine
Basit Elahi
29-Jan-14 8:13am
View
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace nested_gridview_from_vb
{
public partial class WebForm1 : System.Web.UI.Page , ITemplate
{
protected void Page_Load(object sender, EventArgs e)
{
hitechLatestEntities database = new hitechLatestEntities();
GridView1.DataSource = database.HEADs;
TemplateField tfObject = new TemplateField();
tfObject.HeaderText = "Sub-Heads Details";
tfObject.ItemTemplate = new WebForm1(ListItemType.Item);
GridView1.Columns.Insert(0,tfObject);
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string headCode = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
hitechLatestEntities data = new hitechLatestEntities();
var result = from t in data.SUB_HEAD
join x in data.HEADs on t.head_code equals x.head_code
where t.head_code == headCode
select new { t.sub_head_code,t.particulars };
GridView sub = e.Row.FindControl("newg") as GridView;
sub.DataSource = result;
sub.DataBind();
}
}
public WebForm1()
{
}
public WebForm1(ListItemType Item)
{
myListItemType = Item;
}
private ListItemType myListItemType;
public void InstantiateIn(Control container)
{
if (myListItemType == ListItemType.Item)
{
hitechLatestEntities data = new hitechLatestEntities();
GridView newgrid = new GridView();
newgrid.ID = "newg";
newgrid.DataSource = data.SUB_HEAD;
newgrid.DataBind();
container.Controls.Add(newgrid);
}
}
}
Basit Elahi
29-Jan-14 8:10am
View
for now it has two columns. yes i am doing it from code behind
Basit Elahi
29-Jan-14 8:05am
View
i have updated the question. please check it
Basit Elahi
29-Jan-14 7:50am
View
can u give me some example ravikhoda??
Basit Elahi
29-Jan-14 7:38am
View
<asp:GridView ID="GridView1" runat="server"
onrowdatabound="GridView1_RowDataBound" DataKeyNames="head_code" >
I am doing most of the work programatically
Basit Elahi
29-Jan-14 5:27am
View
Thanks a lot @JoCodes. Problem solved..!!!
Basit Elahi
29-Jan-14 4:09am
View
yes data is being fetched by RowDataBound but problem is that same child grid is showing up in each row. i want child gridview according to parent gridview key.
Basit Elahi
29-Jan-14 4:07am
View
i did like this
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string headCode = GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); /* it is giving error on this line as "Index was out of range. Must be non-negative and less than the size of the collection" */
hitechLatestEntities data = new hitechLatestEntities();
var result = from t in data.SUB_HEAD
join x in data.HEADs on t.head_code equals x.head_code
where t.head_code == "headCode"
select t;
GridView sub = e.Row.FindControl("newgrid") as GridView;
sub.DataSource = result; /* also on this line as "Object reference not set to an instance of an object." */
sub.DataBind();
}
}
when i put try catch around it, it shows the same result as previous. but child grid is showing up in every row whether it is of that head or not.
Show More