GriedVIew, ItemtTemplate

Last post 11-07-2009 3:08 PM by nsap. 5 replies.

Sort Posts:

  • GriedVIew, ItemtTemplate

    11-06-2009, 9:29 PM
    • Member
      1 point Member
    • nsap
    • Member since 08-02-2009, 1:44 PM
    • Posts 13

    Hello all,


    I have an assignment and chosed ASP.

    The issue is if by using GRIEDVIEW I can turn what i have done up to now,

    to what ideally I would like to do..


    Griedview gets information from 4 columns.

    I want to palce the information returned from the last 2 columns below the information obtained from the

    first two.


    For instance a row is like:

    BOOK_IMAGE | LITERAL |WRITER | ISBN


    and i want it like:

    BOOK_IMAGE | LITERAL |

    WRITER          | ISBN


    Is it possible?Maybe with the ItemTemplate somehow..



    Thank you very much in advance.


     






  • Re: GriedVIew, ItemtTemplate

    11-07-2009, 12:38 AM
    Answer
    • Contributor
      2,652 point Contributor
    • imran_khan
    • Member since 03-11-2008, 11:57 AM
    • Ahmedabad
    • Posts 508

    Use Table structure in ItemTemplate.
    See this example.

    <asp:TemplateField>
                    <ItemTemplate>
                        <table cellpadding="2" cellspacing="2" width="100%">
                            <tr>
                                <td>BOOK_IMAGE Template Here</td>
                                <td>|</td>
                                <td>LITERAL</td>
                            </tr>
                            <tr>
                                <td>WRITER</td>
                                <td>|</td>
                                <td>ISBN</td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:TemplateField>


    Regard

    Imrankhan

    Imrankhan
    -----------------------------------------------------
    Always remember to mark as answer on the post that helped you.

    My Blog :
    http://aspnet-solutions.blogspot.com/
    http://javascriptsolution.blogspot.com/
  • Re: GriedVIew, ItemtTemplate

    11-07-2009, 12:43 AM

    hi.

    Suppose Name of columns are  BOOK_IMAGE | LITERAL |WRITER | ISBN respectivly, you can use following  Mark up

    <ItemTemplate>
                        <%#Eval("BOOK_IMAGE")%>
                        |
                        <%#Eval("LITERAL")%>
                        <br />
                        <%#Eval("WRITER")%>
                        |
                        <%#Eval("ISBN")%>
     </ItemTemplate>


    Hope this will help.


    thanks.

  • Re: GriedVIew, ItemtTemplate

    11-07-2009, 1:11 AM
    • Member
      96 point Member
    • vrain
    • Member since 03-09-2009, 9:37 AM
    • India, Mumbai
    • Posts 42

     <ItemTemplate>   

                 (In Template Field 1)

                       BOOK_IMAGE </br>

                       LITERAL

                 (In Template Field 2)

                       WRITER </br>

                       ISBN

    </ItemTemplate>   

  • Re: GriedVIew, ItemtTemplate

    11-07-2009, 12:53 PM
    • Member
      1 point Member
    • nsap
    • Member since 08-02-2009, 1:44 PM
    • Posts 13
     





    Hi again,
    Thank you all very much for replying.



    It seems to be a little bit more complicated after all..
    At that moment i use ImageField and HyperlinnkField as well as ItemTemplates to have all
    results in the same line.

    What you get is: IMAGE | Tite: TitleHyperlink | written by | Author_First_Name | Author_Last_Name

    Adding a table was the ideal sollution..
    However, ImageField and HyperLinkField can not be nested in the ItemTemplate.
    I suppose i have to use the Image and the Hyperlink controls respectively,but they don't have the
    appropriate properties for setting the values for the parameters i' am using now..
    Here's the current version of the code:


    <asp:GridView id="grdBooks"
    DataSourceID="srcBooks"
    AutoGenerateColumns="false"
    ShowHeader="False"
    AllowPaging="true"
    PageSize="2"
    CssClass="grdBooks"
    RowStyle-CssClass="row"
    OnDataBound="grdBooks_DataBound"
    PagerStyle-CssClass="PagerClass"
    GridLines="None"
    BorderStyle="None"
    OnRowDataBound="grdBooks_RowDataBound"
    Runat="server" >




    <Columns>


    <asp:ImageField
    DataImageUrlField="Image"
    DataImageUrlFormatString="Book_Images/{0}"
    DataAlternateTextField="Title"
    NullImageUrl="Book_Images/No_Image.jpg"
    />




    <asp:TemplateField>
    <ItemTemplate>

    <asp:Literal ID="Literal1" runat="server">Title: </asp:Literal>

    </ItemTemplate>
    </asp:TemplateField>



    <asp:HyperLinkField

    DataTextField="Title"
    DataNavigateUrlFields="Product_ID"
    ControlStyle-CssClass="SingleProductHyperlink"
    DataNavigateUrlFormatString="Details.aspx?Product_ID={0}" />



    <asp:TemplateField>
    <ItemTemplate>

    <asp:Literal ID="Literal1" runat="server"> Written by </asp:Literal>

    <%# Eval("First_Name")%>

    <asp:Literal ID="Literal2" runat="server"> </asp:Literal>

    <%# Eval("Last_Name")%>

    </ItemTemplate>
    </asp:TemplateField>




    </Columns>

    Any ideas or pin point to other related posts is welcome..


  • Re: GriedVIew, ItemtTemplate

    11-07-2009, 3:08 PM
    • Member
      1 point Member
    • nsap
    • Member since 08-02-2009, 1:44 PM
    • Posts 13

    Ok, I should be ashamed of my self,this is how it is done: (for future reference for any newbie like myslef)


    The only thing now is how to have a "NullImageUrl" in the Image control, when an image field is NULL..



    Kind Regards.



    <asp:TemplateField> 

    <ItemTemplate>



    <asp:Table CssClass="SingleProductTable" CellSpacing="0" CellPadding="0" BorderWidth="1px" GridLines="Both" ID="Table1" runat="server">


    <asp:TableRow CssClass=" SingleProductTableRow">

    <asp:TableCell RowSpan="3">

    <asp:Image ID="Image1" AlternateText='<%# Eval("Title")%>' ImageUrl= '<%# "Book_Images/" + Eval("Image").ToString() %>' runat="server" />

    </asp:TableCell>


    <asp:TableCell>

    <asp:Literal ID="Literal3" runat="server">Title: </asp:Literal>


    <asp:HyperLink CssClass="SingleProductHyperlink" ID="HyperLbfgink42" NavigateUrl='<%# "Details.aspx?Product_ID=" + Eval("Product_ID").ToString()%>' runat="server"><%# Eval("Title")%> </asp:HyperLink>

    </asp:TableCell>


    </asp:TableRow>


    <asp:TableRow CssClass=" SingleProductTableRow">

    <asp:TableCell>

    <asp:Literal ID="Literal1" runat="server">Written by </asp:Literal>

    <%# Eval("First_Name")%>

    <asp:Literal ID="Literal2" runat="server">   </asp:Literal>

    <%# Eval("Last_Name")%>

    </asp:TableCell>

    </asp:TableRow>

    </asp:Table>


    </ItemTemplate>

    </asp:TemplateField>








Page 1 of 1 (6 items)