我在编辑列的时候,增加一个imagefield,在他的属性DataAlternateTextField中设置了数据中存放图片路径的字段,结果发布页面的时候,图片路径后面多了一串字符。这样:http://localhost:23904/test/images/01.gif%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20正常应该是:http://localhost:23904/test/images/01.gif

解决方案 »

  1.   

    你把gridview这段html代码以及后台相关代码贴出来吧
      

  2.   

    DataAlternateTextField 是当图片不显示的时候显示的文字说明设置 DataImageUrlField 为图片地址
      

  3.   

    说错了,DataImageUrlField设置的图片地址
    DataAlternateTextField我也放置了图片地址,但是它显示的就是images/01.gif而图片的url 显示的是:http://localhost:23904/test/images/01.gif%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20
      

  4.   

    <td>7777</td><td><img src="images/02.gif%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20" alt="images/02.gif                                     " style="border-width:0px;" /></td>
    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" AllowPaging="True" AllowSorting="True">
                <Columns>
                    <asp:BoundField DataField="pID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                        SortExpression="pID" />
                    <asp:BoundField DataField="pName" HeaderText="名称" SortExpression="pName" />
                    <asp:BoundField DataField="pSex" HeaderText="性别" SortExpression="pSex" />
                    <asp:BoundField DataField="pOther" HeaderText="其他" SortExpression="pOther" />
                    <asp:BoundField DataField="pSalary" HeaderText="薪水" SortExpression="pSalary" />
                    <asp:ImageField DataAlternateTextField="imgUrl" DataImageUrlField="imgUrl" HeaderText="图片">
                    </asp:ImageField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString2 %>" SelectCommand="SELECT * FROM [people]"></asp:SqlDataSource>