nested grid view

AustinPowers

New Member
I like to use 1 nested grid view for showing the result like below, column 1 & column 2 are for main gridview and column 3 is for nested gridview.Main gridview , nested gridview are control of an user control.I like my result was like below:\[code\]TransId Transmittal TranstoCon 1 TT-0001 TT-CON-0005 TT-CON-0100\[/code\]\[code\] 2 TT-0009 TT-CON-3000\[/code\]but after running , my grid view shows like below (Duplicate records):\[code\]TransId Transmittal TranstoCon 1 TT-0001 TT-CON-0005 TT-CON-0100 TT-CON-3000 1 TT-0001 TT-CON-0005 TT-CON-0100 TT-CON-3000 1 TT-0001 TT-CON-0005 TT-CON-0100 TT-CON-3000 2 TT-0009 TT-CON-0005 TT-CON-0100 TT-CON-3000\[/code\]Please help what is the problem .How I can solve it.The code of user control is like below:\[code\]public partial class Transmittallistfortest : System.Web.UI.UserControl{class TransmittaltoConPresentationModel{ public int TransID { get; set; } public String Transmittal { get; set; } public IEnumerable<tblTranstoCon> TranstoCons { get; set; }}public class tbltransmittalNoEventArgs : EventArgs{ public int TransmittalId { get; set; }}public event EventHandler<tbltransmittalNoEventArgs> DeleteTransmittal;private IEnumerable<tbltransmittalNo> _Transmittals;public IEnumerable<tbltransmittalNo> Transmittals{ set { _Transmittals = value; }}private IEnumerable<tblTranstoCon> _Transmittaltocons;public IEnumerable<tblTranstoCon> Transmittaltocons{ set { _Transmittaltocons = value; }}private IEnumerable<tblDocTranstoCon> _DocTranstoCons;public IEnumerable<tblDocTranstoCon> DocTranstoCons{ set { _DocTranstoCons = value; }}public IEnumerable<tblTransmittall> tblTransmittall{ set; private get;}public int Doc{ set; private get;}protected void Page_Load(object sender, EventArgs e){}public override void DataBind(){ base.DataBind(); if (_Transmittals != null) { DisplayTransmittals(); }}private void DisplayTransmittals(){ if (_Transmittals != null) { var query = from transmittalno in _Transmittals from Transmittal in tblTransmittall from doctranstocon in _DocTranstoCons from transtocon in _Transmittaltocons where ((transmittalno.TransID == Transmittal.TransId) && (Transmittal.TransId == doctranstocon.Transid) && (Transmittal.DocID == doctranstocon.Docid) && (doctranstocon.TransmitToConid == transtocon.TRANSMITtoConId)) select new TransmittaltoConPresentationModel { TransID = transmittalno.TransID, Transmittal = transmittalno.TRANSMITTAL.ToString(), TranstoCons = from x in _Transmittaltocons select x }; GridViewTtransmittals.DataSource = query; } else { GridViewTtransmittals.DataSource = null; } GridViewTtransmittals.DataBind();}protected void GridViewTtransmittals_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.DataItem == null) return; TransmittaltoConPresentationModel transmittaltoCon = (TransmittaltoConPresentationModel)e.Row.DataItem; GridView g2 = (GridView)e.Row.FindControl("GridViewTranstoCon"); g2.DataSource = transmittaltoCon.TranstoCons; g2.DataBind();}\[/code\]
 
Back
Top