473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to access Datagrid in a datagrid

Hi,
i have a DataGrid by Name : datagrid1 and in that i had created one templete
Column and Added a new datagrid : datagrid2.
Now i want to access that datagrid2 how is it possiable. and populate the
same datawhich is preset in the datagrid1.

Raghuram
Nov 19 '05 #1
1 1260
use the following code (sorry its in C#)

in Page_Load

DataGrid1.ItemCreated += new
DataGridItemEventHandler(DataGrid1_ItemCreated);
//bind your first grid
DataGrid1.DataSource = data;
DataGrid1.DataBind();

create the following method

private void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs
e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem
|| e.Item.ItemType == ListItemType.Item)
{
//find the control by referencing the col number
//if the template col is in the first col then
//use index 0
DataGrid DataGrid2 =
(DataGrid)e.Item.Cells[0].FindControl("DataGrid2");
//use whatever data source you need
DataGrid2.DataSource = new string[3]{"ab", "cd", "ef"};
DataGrid2.DataBind();
}
}

------ this is the html code

<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns=False>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DataGrid ID="DataGrid2" Runat="server"></asp:DataGrid>
<br>
rest of template
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

-----

http://garethjames.blogspot.com/

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: StepUP | last post by:
I'm a long time developer in Access. Noticing the "Why do IT guys hate MS Access?" thread made me think of my recent experiences in experimenting with VB .Net, and specifically, the Datagrid...
0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
1
by: bill yeager | last post by:
I did some more debugging and found the following: 1) I placed the following code in the button event just to see if I could cycle thru the datagrid control collection: <code> Dim strhello As...
3
by: Michael | last post by:
Does anyone know how to export a data grid from asp.net into microsoft access? Thanks. Michael
0
by: Qajussi | last post by:
Hi! I am trying to create data entry forms like MS access forms using asp.net. I am talking about a form like MS access forms which let you enter a new record, edit, navigate to previous and next...
1
by: Sean | last post by:
What is the best way to access the Underlying data of a DataGrid. I have two SQL tables joined and display some data from both, but I want to be able to on clicking of a row bring up a form that...
3
by: Marco de Vries | last post by:
I used to work a lot with Access and created many access databases One thing I'm missing right now is the Access Datagrid displayed when you open a table I looked at a lot of datagrids and read...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
4
by: _MC_ | last post by:
Hi, I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1 Cell. So here it is: The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns are added on...
1
by: psyvanz | last post by:
i have created 2 tables name table1 and table2 with the same fieldnames in subjectnumber(sub-0001), subjectname(english1) but in my table2 i added studentnumber(s-0001) and studentname(paul) im...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.