|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ItemDataBound fires for header onlyThis is driving me crazy. I need to hide rows that a particular cell is
zero. On debuggng I fiound out that ItemDataBound fires for header only and not for Item and AlternatingItem private void grdSelectionList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ) { if (e.Item.Cells[2].Text == "0") { e.Item.Visible = false; } } Any help on this will be appreciated. That piece of code you pasted should work well. Your code also eliminates
the header row. Look for the problem some place else. If you still cannot resolve, paste the rest of the code you have. Regards, Alessandro Zifiglio http://www.AsyncUI.net <bkas***@gmail.com> ha scritto nel messaggio Show quoteHide quote news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... > This is driving me crazy. I need to hide rows that a particular cell is > zero. On debuggng I fiound out that ItemDataBound fires for header only > and not for Item and AlternatingItem > private void grdSelectionList_ItemDataBound(object sender, > System.Web.UI.WebControls.DataGridItemEventArgs e) > { > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == > ListItemType.AlternatingItem ) > { > if (e.Item.Cells[2].Text == "0") > { > e.Item.Visible = false; > } > } > > Any help on this will be appreciated. > also, unless your datasource is not returning any rows, in which case only
the header row will show. This is logical ofcourse =P Regards, Alessandro Zifiglio http://www.AsyncUI.net Show quoteHide quote "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto nel messaggio news:%23nBc%23tjrGHA.4912@TK2MSFTNGP05.phx.gbl... > That piece of code you pasted should work well. Your code also eliminates > the header row. > > Look for the problem some place else. If you still cannot resolve, paste > the rest of the code you have. > Regards, > Alessandro Zifiglio > http://www.AsyncUI.net > > <bkas***@gmail.com> ha scritto nel messaggio > news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... >> This is driving me crazy. I need to hide rows that a particular cell is >> zero. On debuggng I fiound out that ItemDataBound fires for header only >> and not for Item and AlternatingItem >> private void grdSelectionList_ItemDataBound(object sender, >> System.Web.UI.WebControls.DataGridItemEventArgs e) >> { >> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == >> ListItemType.AlternatingItem ) >> { >> if (e.Item.Cells[2].Text == "0") >> { >> e.Item.Visible = false; >> } >> } >> >> Any help on this will be appreciated. >> > > The datasource returns many rows. On testing, the itemDataBind fires
only once and e.Item.ItemType.TString() return 'header' Alessandro Zifiglio wrote: Show quoteHide quote > also, unless your datasource is not returning any rows, in which case only > the header row will show. This is logical ofcourse =P > > Regards, > Alessandro Zifiglio > http://www.AsyncUI.net > > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto > nel messaggio news:%23nBc%23tjrGHA.4912@TK2MSFTNGP05.phx.gbl... > > That piece of code you pasted should work well. Your code also eliminates > > the header row. > > > > Look for the problem some place else. If you still cannot resolve, paste > > the rest of the code you have. > > Regards, > > Alessandro Zifiglio > > http://www.AsyncUI.net > > > > <bkas***@gmail.com> ha scritto nel messaggio > > news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... > >> This is driving me crazy. I need to hide rows that a particular cell is > >> zero. On debuggng I fiound out that ItemDataBound fires for header only > >> and not for Item and AlternatingItem > >> private void grdSelectionList_ItemDataBound(object sender, > >> System.Web.UI.WebControls.DataGridItemEventArgs e) > >> { > >> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == > >> ListItemType.AlternatingItem ) > >> { > >> if (e.Item.Cells[2].Text == "0") > >> { > >> e.Item.Visible = false; > >> } > >> } > >> > >> Any help on this will be appreciated. > >> > > > > I now know the cause of the problem but not the solution. The column 2
is a TemplateColumn populated with data but e.Item.Cells[2].Text returns empty string. All other cells which are databond return correct values. This seems to be a fundamental misunderstandig on my behalf. Any idea how can I solve this? Barbra bkas***@gmail.com wrote: Show quoteHide quote > The datasource returns many rows. On testing, the itemDataBind fires > only once and e.Item.ItemType.TString() return 'header' > > > Alessandro Zifiglio wrote: > > also, unless your datasource is not returning any rows, in which case only > > the header row will show. This is logical ofcourse =P > > > > Regards, > > Alessandro Zifiglio > > http://www.AsyncUI.net > > > > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto > > nel messaggio news:%23nBc%23tjrGHA.4912@TK2MSFTNGP05.phx.gbl... > > > That piece of code you pasted should work well. Your code also eliminates > > > the header row. > > > > > > Look for the problem some place else. If you still cannot resolve, paste > > > the rest of the code you have. > > > Regards, > > > Alessandro Zifiglio > > > http://www.AsyncUI.net > > > > > > <bkas***@gmail.com> ha scritto nel messaggio > > > news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... > > >> This is driving me crazy. I need to hide rows that a particular cell is > > >> zero. On debuggng I fiound out that ItemDataBound fires for header only > > >> and not for Item and AlternatingItem > > >> private void grdSelectionList_ItemDataBound(object sender, > > >> System.Web.UI.WebControls.DataGridItemEventArgs e) > > >> { > > >> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == > > >> ListItemType.AlternatingItem ) > > >> { > > >> if (e.Item.Cells[2].Text == "0") > > >> { > > >> e.Item.Visible = false; > > >> } > > >> } > > >> > > >> Any help on this will be appreciated. > > >> > > > > > > Found the solution! For TemplateColumn the FindControl must be used:
Label lbl = (Label)e.Item.Cells[2].FindControl("label_ID"); if (lbl.Text == "0") { e.Item.Visible = false; } bkas***@gmail.com wrote: Show quoteHide quote > I now know the cause of the problem but not the solution. The column 2 > is a TemplateColumn populated with data but e.Item.Cells[2].Text > returns empty string. All other cells which are databond return correct > values. This seems to be a fundamental misunderstandig on my behalf. > Any idea how can I solve this? > Barbra > bkas***@gmail.com wrote: > > The datasource returns many rows. On testing, the itemDataBind fires > > only once and e.Item.ItemType.TString() return 'header' > > > > > > Alessandro Zifiglio wrote: > > > also, unless your datasource is not returning any rows, in which case only > > > the header row will show. This is logical ofcourse =P > > > > > > Regards, > > > Alessandro Zifiglio > > > http://www.AsyncUI.net > > > > > > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto > > > nel messaggio news:%23nBc%23tjrGHA.4912@TK2MSFTNGP05.phx.gbl... > > > > That piece of code you pasted should work well. Your code also eliminates > > > > the header row. > > > > > > > > Look for the problem some place else. If you still cannot resolve, paste > > > > the rest of the code you have. > > > > Regards, > > > > Alessandro Zifiglio > > > > http://www.AsyncUI.net > > > > > > > > <bkas***@gmail.com> ha scritto nel messaggio > > > > news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... > > > >> This is driving me crazy. I need to hide rows that a particular cell is > > > >> zero. On debuggng I fiound out that ItemDataBound fires for header only > > > >> and not for Item and AlternatingItem > > > >> private void grdSelectionList_ItemDataBound(object sender, > > > >> System.Web.UI.WebControls.DataGridItemEventArgs e) > > > >> { > > > >> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == > > > >> ListItemType.AlternatingItem ) > > > >> { > > > >> if (e.Item.Cells[2].Text == "0") > > > >> { > > > >> e.Item.Visible = false; > > > >> } > > > >> } > > > >> > > > >> Any help on this will be appreciated. > > > >> > > > > > > > > glad you resolved the issue.
have a good day, Alessandro Zifiglio http://www.AsyncUI.net <bkas***@gmail.com> ha scritto nel messaggio Show quoteHide quote news:1153651713.822218.57320@b28g2000cwb.googlegroups.com... > Found the solution! For TemplateColumn the FindControl must be used: > > Label lbl = (Label)e.Item.Cells[2].FindControl("label_ID"); > if (lbl.Text == "0") > { > e.Item.Visible = false; > } > > bkas***@gmail.com wrote: >> I now know the cause of the problem but not the solution. The column 2 >> is a TemplateColumn populated with data but e.Item.Cells[2].Text >> returns empty string. All other cells which are databond return correct >> values. This seems to be a fundamental misunderstandig on my behalf. >> Any idea how can I solve this? >> Barbra >> bkas***@gmail.com wrote: >> > The datasource returns many rows. On testing, the itemDataBind fires >> > only once and e.Item.ItemType.TString() return 'header' >> > >> > >> > Alessandro Zifiglio wrote: >> > > also, unless your datasource is not returning any rows, in which case >> > > only >> > > the header row will show. This is logical ofcourse =P >> > > >> > > Regards, >> > > Alessandro Zifiglio >> > > http://www.AsyncUI.net >> > > >> > > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha >> > > scritto >> > > nel messaggio news:%23nBc%23tjrGHA.4912@TK2MSFTNGP05.phx.gbl... >> > > > That piece of code you pasted should work well. Your code also >> > > > eliminates >> > > > the header row. >> > > > >> > > > Look for the problem some place else. If you still cannot resolve, >> > > > paste >> > > > the rest of the code you have. >> > > > Regards, >> > > > Alessandro Zifiglio >> > > > http://www.AsyncUI.net >> > > > >> > > > <bkas***@gmail.com> ha scritto nel messaggio >> > > > news:1153641920.848351.4990@b28g2000cwb.googlegroups.com... >> > > >> This is driving me crazy. I need to hide rows that a particular >> > > >> cell is >> > > >> zero. On debuggng I fiound out that ItemDataBound fires for header >> > > >> only >> > > >> and not for Item and AlternatingItem >> > > >> private void grdSelectionList_ItemDataBound(object sender, >> > > >> System.Web.UI.WebControls.DataGridItemEventArgs e) >> > > >> { >> > > >> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == >> > > >> ListItemType.AlternatingItem ) >> > > >> { >> > > >> if (e.Item.Cells[2].Text == "0") >> > > >> { >> > > >> e.Item.Visible = false; >> > > >> } >> > > >> } >> > > >> >> > > >> Any help on this will be appreciated. >> > > >> >> > > > >> > > > >
WebForm UserControl ?s
DropdownList problem with internet explorer Firing events for child controls inside a DataGrid Custom Server Control Problem with HTML in ASP.Net App CustomValidator How-to link 2 Detailsview Formview child control data retrieval Retireve data with SqlDatasource & dynamically manipulate before dispalying Can a Repeater control repeat an .ascx? |
|||||||||||||||||||||||