Sanjeet
asked on
Acessing a datagrid from a control using findcontrol.
I have an ascx page called main.ascx.
Main.ascx contains 2 controls. dailyevents1 and concuentevents1
Each of these controls contains a datagrid.
the main.ascx page also contains a submit link.
the submit link should sum up the contents of the 5th column in eash datagrid and display the total at the bottom of each datagrid.
I have this so far I just need to reference the datagrids using the find control method:
private void lbsubmit_Click(object sender, System.EventArgs e)
{
dailyEvent = FindControl( "DailyEvent1") as DailyEvent;
DataGrid dg = FindControl( "DailyEvent1" ) as DataGrid;
TextBox tb = (TextBox)e.Item.Cells[5].F indControl ("txtCredi tsClaimed" );
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt em)
{
//if(e.Item.Cells[5].Text. ToString() != null || e.Item.Cells[5].Text.ToStr ing().Leng th > 0 )
if(e.Item.Cells[5].Text.To String().L ength > 0 )
{
CalcTotal( e.Item.Cells[5].Text);
e.Item.Cells[5].Text =string.Format("{0:c}", Convert.ToDouble(e.Item.Ce lls[5].Tex t));
}
}
else if(e.Item.ItemType == ListItemType.Footer )
{
e.Item.Cells[4].Text="Tota l";
e.Item.Cells[5].Text = string.Format("{0:c}", runningTotal);
}
}
Says I cannot use e.items. How do I refereance txtCreditsClaimed inside the datagrid from this submit link.
Main.ascx contains 2 controls. dailyevents1 and concuentevents1
Each of these controls contains a datagrid.
the main.ascx page also contains a submit link.
the submit link should sum up the contents of the 5th column in eash datagrid and display the total at the bottom of each datagrid.
I have this so far I just need to reference the datagrids using the find control method:
private void lbsubmit_Click(object sender, System.EventArgs e)
{
dailyEvent = FindControl( "DailyEvent1") as DailyEvent;
DataGrid dg = FindControl( "DailyEvent1" ) as DataGrid;
TextBox tb = (TextBox)e.Item.Cells[5].F
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt
{
//if(e.Item.Cells[5].Text.
if(e.Item.Cells[5].Text.To
{
CalcTotal( e.Item.Cells[5].Text);
e.Item.Cells[5].Text =string.Format("{0:c}", Convert.ToDouble(e.Item.Ce
}
}
else if(e.Item.ItemType == ListItemType.Footer )
{
e.Item.Cells[4].Text="Tota
e.Item.Cells[5].Text = string.Format("{0:c}", runningTotal);
}
}
Says I cannot use e.items. How do I refereance txtCreditsClaimed inside the datagrid from this submit link.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.