在asp.net的数据gridview中进行编辑时如何获取水平滚动?

时间:2019-03-28 15:46:25

标签: c# asp.net gridview

[单击编辑按钮后,gridview扩大了,但是我找不到任何水平滚动条,因此无法将数据保存到该行。我该如何解决这个问题?而且我也无法在行更新中编辑图片。][1]

[这里是问题所在。我还使用了tinymce来编辑描述。  这是此网格视图的代码

<asp:GridView ID="GridView_show_product" runat="server" AutoGenerateColumns="false"  DataKeyNames="product_id" 
            style="height:400px; overflow-x:scroll;margin:5px"
            ShowHeaderWhenEmpty="true" OnRowCancelingEdit="grid_RowCancelingEdit"
            OnRowUpdating="grid_RowUpdating" OnRowDeleting="grid_RowDeleting" 
            OnRowEditing="grid_RowEditing"

    BackColor="White" BorderColor="#000000" BorderStyle="Solid"  CellPadding="3" CellSpacing="2" BorderWidth="0" width="500px" >
            <%-- Theme Properties --%>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#0e8ce4" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
            <Columns>
                <asp:TemplateField HeaderText="Product Id" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_product_id" Text='<%# Eval("product_id") %>' runat="server"/>
                    </ItemTemplate>          
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Product Code" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_product_code" Text='<%# Eval("product_code") %>' runat="server" />
                </ItemTemplate>                        
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Product Type" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_product_type" Text='<%# Eval("product_type") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_product_type" Text='<%# Eval("product_type") %>' runat="server" />
                    </EditItemTemplate>                       
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Product Name" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_product_name" Text='<%# Eval("product_name") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_product_name" Text='<%# Eval("product_name") %>' runat="server" />
                    </EditItemTemplate>                       
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Price" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_price" Text='<%# Eval("product_price") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_price" Text='<%# Eval("product_price") %>' runat="server" TextMode="Number" />
                    </EditItemTemplate>                       
                </asp:TemplateField>

                <asp:TemplateField HeaderText="In Stock" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_stock" Text='<%# Eval("product_stock") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_stock" Text='<%# Eval("product_stock") %>' runat="server" />
                    </EditItemTemplate>                       
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Brand Name" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_brand_name" Text='<%# Eval("brand_name") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_brand_name" Text='<%# Eval("brand_name") %>' runat="server" />
                    </EditItemTemplate>                 
                </asp:TemplateField>

                <%--image--%>
                <asp:TemplateField HeaderText="Product Image" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" Height="100px" Width="100px"
                            ImageUrl='<%# "data:Image/png;base64,"
                                + Convert.ToBase64String((byte[])Eval("product_image")) %>' />
                    </ItemTemplate>
                    <%--<EditItemTemplate>
                        <asp:FileUpload ID="FileUpload_image" runat="server" />
                    </EditItemTemplate>--%>                       
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Product Description" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>

                        <div id="Div_description" runat="server" style="overflow-y:scroll;overflow-x:scroll;width:150px;height:100px;padding:20px;"><%# Eval("product_description") %></div>

                    </ItemTemplate>
                    <EditItemTemplate>
                        <script type="text/javascript" src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
                            <script type="text/javascript">
                                tinymce.init({ selector: 'textarea', width: 300,height:100 });
                            </script>
                        <asp:TextBox ID="TextBox_description" Text='<%# Eval("product_description") %>' runat="server" TextMode="MultiLine" />
                    </EditItemTemplate>                  
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Medicine Composition" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label_composition" Text='<%# Eval("product_composition") %>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox_composition" Text='<%# Eval("product_composition") %>' runat="server" />
                    </EditItemTemplate>                      
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Operations" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton1" ImageUrl="~/Images/edit.png" runat="server" CommandName="Edit" ToolTip="Edit" Width="20px" Height="20px"/>
                        <asp:ImageButton ID="ImageButton2" ImageUrl="~/Images/delete.png" runat="server" CommandName="Delete" ToolTip="Delete" Width="20px" Height="20px"/>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:ImageButton ID="ImageButton3" ImageUrl="~/Images/save.png" runat="server" CommandName="Update" ToolTip="Update" Width="20px" Height="20px"/>
                        <asp:ImageButton ID="ImageButton4" ImageUrl="~/Images/cancel.png" runat="server" CommandName="Cancel" ToolTip="Cancel" Width="20px" Height="20px"/>
                    </EditItemTemplate>

                </asp:TemplateField>
            </Columns>
        </asp:GridView>

] 2

0 个答案:

没有答案