Click here to Skip to main content
15,922,696 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Working with dynamically created controls Pin
rahul.net1130-Dec-07 19:40
rahul.net1130-Dec-07 19:40 
GeneralRe: Working with dynamically created controls Pin
Paul Conrad31-Dec-07 5:56
professionalPaul Conrad31-Dec-07 5:56 
GeneralRe: Working with dynamically created controls Pin
Imran Khan Pathan30-Dec-07 19:52
Imran Khan Pathan30-Dec-07 19:52 
GeneralRe: Working with dynamically created controls Pin
Paul Conrad31-Dec-07 5:56
professionalPaul Conrad31-Dec-07 5:56 
Questionhow to retrive image from database change automatically into time interval Pin
ramesh_imayam30-Dec-07 18:53
ramesh_imayam30-Dec-07 18:53 
AnswerRe: how to retrive image from database change automatically into time interval Pin
Paul Conrad30-Dec-07 18:59
professionalPaul Conrad30-Dec-07 18:59 
GeneralWeird issue with nested datagrid Pin
N a v a n e e t h30-Dec-07 18:52
N a v a n e e t h30-Dec-07 18:52 
GeneralRe: Weird issue with nested datagrid Pin
Michael Sync30-Dec-07 19:44
Michael Sync30-Dec-07 19:44 
Hi man,

I think you might put the event handler of child grid after binding. I have tested and it works fine..

HTML
====

<![CDATA[<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication4.WebForm1" %>]]>

<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</meta></meta></meta></meta></head>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server">
<columns>
<asp:boundcolumn datafield="C1"></asp:boundcolumn>
<asp:boundcolumn datafield="C2"></asp:boundcolumn>
<asp:templatecolumn>
<itemtemplate>
<asp:datagrid id="DataGrid2" runat="server">
<columns>
<asp:boundcolumn datafield="C1"></asp:boundcolumn>
<asp:templatecolumn>
<itemtemplate>
<asp:hyperlink navigateurl="http://michaelsync.net" id="hypLink" runat="server">
&lt;%# DataBinder.Eval(Container, "DataItem.C2") %&gt;
</asp:hyperlink>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
</form>
</body>
</html>


Code-behinded file
==================

protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
DataGrid1.ItemDataBound +=new DataGridItemEventHandler(DataGrid1_ItemDataBound);
DataGrid1.DataSource = getDataTable();
DataGrid1.DataBind();

}
private DataTable getDataTable()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("C1" );
dt.Columns.Add("C2");
ds.Tables.Add(dt);
for(int i=0; i&lt;5;i++)
{
DataRow dr = dt.NewRow();
dr[0] = i.ToString();
dr[1] = "C2" + i.ToString();

dt.Rows.Add(dr);
}
return dt;
}

DataGrid dg = new DataGrid();

private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
dg = (DataGrid)e.Item.FindControl("DataGrid2");
if(dg != null)
{
dg.ItemDataBound +=new DataGridItemEventHandler(dg_ItemDataBound);
dg.DataSource = getDataTable();
dg.DataBind();
}
}

private void dg_ItemDataBound(object sender, DataGridItemEventArgs e)
{
HyperLink hlink = (HyperLink)e.Item.FindControl("hypLink");
if(hlink != null)
{
hlink.ForeColor= System.Drawing.Color.Red;
}
}

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)


GeneralRe: Weird issue with nested datagrid Pin
Michael Sync30-Dec-07 19:48
Michael Sync30-Dec-07 19:48 
GeneralRe: Weird issue with nested datagrid Pin
N a v a n e e t h30-Dec-07 19:56
N a v a n e e t h30-Dec-07 19:56 
GeneralRe: Weird issue with nested datagrid Pin
Michael Sync30-Dec-07 20:02
Michael Sync30-Dec-07 20:02 
GeneralRe: Weird issue with nested datagrid Pin
N a v a n e e t h30-Dec-07 20:12
N a v a n e e t h30-Dec-07 20:12 
GeneralRe: Weird issue with nested datagrid Pin
Michael Sync30-Dec-07 20:19
Michael Sync30-Dec-07 20:19 
GeneralRe: Weird issue with nested datagrid Pin
N a v a n e e t h30-Dec-07 20:20
N a v a n e e t h30-Dec-07 20:20 
GeneralRe: Weird issue with nested datagrid Pin
Michael Sync30-Dec-07 20:24
Michael Sync30-Dec-07 20:24 
GeneralRe: Weird issue with nested datagrid Pin
Vasudevan Deepak Kumar2-Jan-08 20:11
Vasudevan Deepak Kumar2-Jan-08 20:11 
Questionhow to increase the speed of an application Pin
jagan12330-Dec-07 18:21
jagan12330-Dec-07 18:21 
AnswerRe: how to increase the speed of an application Pin
Michael Sync30-Dec-07 18:33
Michael Sync30-Dec-07 18:33 
AnswerRe: how to increase the speed of an application Pin
Paul Conrad30-Dec-07 19:02
professionalPaul Conrad30-Dec-07 19:02 
GeneralRe: how to increase the speed of an application Pin
jagan12330-Dec-07 19:07
jagan12330-Dec-07 19:07 
GeneralRe: how to increase the speed of an application Pin
Paul Conrad30-Dec-07 19:13
professionalPaul Conrad30-Dec-07 19:13 
GeneralRe: how to increase the speed of an application Pin
jagan12330-Dec-07 19:15
jagan12330-Dec-07 19:15 
GeneralRe: how to increase the speed of an application Pin
Paul Conrad30-Dec-07 19:18
professionalPaul Conrad30-Dec-07 19:18 
GeneralRe: how to increase the speed of an application Pin
jagan12330-Dec-07 19:29
jagan12330-Dec-07 19:29 
GeneralRe: how to increase the speed of an application Pin
Paul Conrad31-Dec-07 5:57
professionalPaul Conrad31-Dec-07 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.