ScottForgot Posted November 30, 2005 Posted November 30, 2005 All, In the code below, I display a Name in the left column next to the right column where the doc type in the right column is Typ1. But my real need is to display the name (DataItem.Name) only for the first row and not because it corresponds with doc type Typ1. I've begun to learn a little bit about DataGridItems but need to figure out how to display field values conditioned upon being in a specific row, as in this case, the first row only. Can anyone show me how that would look? I will also need to know how to display the name (DataItem.Name) in place of "Search Results" between my HTML header tags. how can this be accomplished? Thanks all!! = = = = = <h2>Search Results</h2> <form id="Form1" method="post" runat="server" Font-Name="Verdana"> <asp:DataGrid id="dgDoc" runat="server" Autogeneratecolumns=false AllowPaging="True" PageSize="20" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Right" OnPageIndexChanged="dgDoc_Page" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"> <columns> <asp:TemplateColumn HeaderText="Name"> <ItemTemplate> <asp:Label runat="server" Text='<%# iif(DataBinder.Eval(Container.DataItem, "String03")="Typ1",DataBinder.Eval(Container, "DataItem.Name"),"") %>'> </asp:Label> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Document"> <ItemTemplate> <asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "String03") %>' NavigateUrl= '<%# "showDocImages.aspx?NAME=" + DataBinder.Eval(Container, "DataItem.Name") + "&NODE_ID=" + DataBinder.Eval(Container, "DataItem.Node_ID").ToString() + "&SEARCH=" + SESSION("SEARCH") %>' > </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn> <asp:boundcolumn headertext="Name" datafield="Name" visible="false" /> </columns> </asp:DataGrid> <p> <asp:LinkButton id="btnPrev" runat="server" Text="Previous page" CommandArgument="prev" ForeColor="navy" Font-Name="verdana" Font-size="8pt" OnClick="PagerButtonClick" /> <asp:LinkButton id="btnNext" runat="server" Text="Next page" CommandArgument="next" ForeColor="navy" Font-Name="verdana" Font-size="8pt" OnClick="PagerButtonClick" /> <p> <asp:Label id="feedbackLabel" runat="server" BackColor="Wheat" Font-Bold="True" Text="" /> </p> </form> Quote
bri189a Posted November 30, 2005 Posted November 30, 2005 Kind of glanced so I might miss something but have the item you want to control the visibility on be a template column - use a label in the template column and set it's visible property to false. Then on ItemDataBound event check the item index of the current item: If e.Item.ItemIndex = 0 Then 'I assume the template control is in cell 0 - remember hidden cells will be part of the count too. Dim c as Control = e.Item.Cells(0).FindControl("lblNameHere") If Not c Is Nothing Then DirectCast(c, Label).Visible = True End If End If That's a pretty simple way. You could also set the visibility of the label to be databound if you wanted to become more dynamic, but I think this will meet your needs based upon what I glanced at. Quote
ScottForgot Posted November 30, 2005 Author Posted November 30, 2005 bri189a, Thanks much for your response! I slight variation on your suggestion got me there!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.