Как динамически создать вид сетки - PullRequest
0 голосов
/ 26 февраля 2011

Я хочу динамически создавать вид сетки из кода позади.мой код

  <asp:GridView ID="grvwDownloadItems" runat="server" AutoGenerateColumns="False" CellPadding="0"
                        GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                        CellSpacing="1"  ShowHeader="False" Visible="True" HorizontalAlign="Center"
                        OnRowDataBound="grvwDownloadItems_OnRowDataBound" > 
                        <%--  AllowPaging="True" PageSize="10" OnPageIndexChanging="grvwDownloadItems_PageIndexChanging"--%>
                        <%-- <PagerSettings Mode="NextPreviousFirstLast" Position="TopAndBottom" FirstPageText="First"
                                    LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" />
                        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />--%>
                       <PagerStyle HorizontalAlign="Center" BackColor="#C6C3C6" ForeColor="#000066" Font-Bold="True"
                            Font-Size="X-Large" VerticalAlign="Middle" />
                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                        <Columns>
                          <asp:TemplateField>
                            <ItemTemplate>
                              <table width="100%" border="0" cellspacing="1" cellpadding="0">
                                <tr>                                   
                                   <td width="35px" height="50px" align="right" bgcolor="White">                                   
                                    <asp:HyperLink ID="DownloadsInfo" ImageUrl="~/Images/download-button_Small.jpg" runat="server" Target="_blank "
                                      ToolTip='<%# Eval("Download") %>' CssClass="label"
                                      onclick= "window.open (this.href, 'popupwindow', 'height=50,width=100,left=550,top=350'); return false;">
                                    </asp:HyperLink>
                                    <asp:HiddenField ID="IDHiddenField" runat="server" Value='<%# Eval("ID") %>' />
                                   </td>
                                    <td height="40px" valign="top" align="center">
                                        <table width="100%">
                                            <td bgcolor="#012060" height="30px" align="center" width="150px">
                                                <b style="color: White;" class="label">Product</b>
                                            <td bgcolor="#012060" height="30px" align="center" width="165px" >
                                                <b style="color: White;" class="label">Version</b>
                                            </td>
                                             <td bgcolor="#012060" height="30px" align="center" width="100px" >
                                                <b style="color: White;" class="label">FileSize</b>
                                            </td>
                                            <td bgcolor="#012060" height="30px" align="center" width="250px">
                                                <b style="color: White;" class="label">Description</b>
                                            </td>                                        
                                            <td bgcolor="#012060" height="30px" align="center" width="250px">
                                                <b style="color: White;" class="label">Instructions</b>
                                            </td>                                  
                                </tr>
                                <tr valign="top">
                                    <td bgcolor="White" height="40px" width="150px">
                                        <br />
                                        <asp:Label ID="lblProduct" runat="server" CssClass="label" Text='<%# Eval("Product") %>'
                                            ForeColor="#000000" />
                                    </td>
                                     <td bgcolor="White" height="40px" width="165px">
                                        <br />
                                        <asp:Label ID="lblVersion" runat="server" CssClass="label" Text='<%# Eval("Version") %>'
                                            ForeColor="#000000" />
                                    </td>
                                    <td bgcolor="White" height="40px" width="100px">
                                        <br />
                                        <asp:Label ID="lblFileSize" runat="server" CssClass="label" Text='<%# Eval("FileSize") %>'
                                            ForeColor="#000000" />
                                    </td>
                                     <td bgcolor="White" height="40px" width="250px">
                                        <br />
                                        <asp:Label ID="lblDescription" runat="server" CssClass="label" Text='<%# Eval("Description") %>'
                                            ForeColor="#000000" />
                                    </td>
                                    <td bgcolor="White" height="40px" width="250px">
                                        <br />                                        
                                        <asp:Label ID="lblInstructions" runat="server" CssClass="label" Text='<%# Eval("HyperlinkText") %>'
                                            ForeColor="#000000" />
                                       <%-- <asp:HyperLink ID="hlnkInstructions" runat="server" Target="_blank " ToolTip= "Click here..to see Instructions" 
                                        NavigateUrl='<%# Eval("HyperlinkUrl") %>' CssClass="label"><%# Eval("HyperlinkText") %></asp:HyperLink>--%>
                                      <asp:HyperLink ID="hlnkInstructions" runat="server" Target="_blank " ToolTip= "Click here..to see Instructions" 
                                      onclick="window.open (this.href, 'popupwindow', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,
                                             scrollbars=yes,resizable=yes,titlebar=no'); return false;"
                                        NavigateUrl='<%# FetchVal(Eval("HyperlinkUrl")) %>' CssClass="label"><%# Eval("HyperlinkText") %> </asp:HyperLink>
                                    </td>
                                </tr>
                             </table>
                              </td> 
                            </table>
                         </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="ID" HeaderText="IDval" Visible="false"/>
                     </Columns>
                     <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                     <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                 </asp:GridView>

у меня возникли трудности при создании двух полей шаблона в одном столбце

...