gridview问题..我添加下载链接按钮 [英] gridview problems ..wehn i add download linkbutton

查看:101
本文介绍了gridview问题..我添加下载链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有



in m girdview我添加linkbutton downlaod当我运行follwoing错误发生



DataBinding:''System.Data.DataRowView''不包含名为''Uploadfile''的属性。





girdivew是


< asp:GridView ID =   GridView1 runat =   server CellPadding =   4 ForeColor =  #333333 
GridLines = >
< Columns>
< asp:TemplateField>
< ItemTemplate>
< asp:LinkBut​​ton ID = Linkdwnld runat = server
CommandArgument = ' <%#Eval(Uploadfile)%>' CommandName = cmd>下载< / asp:LinkBut​​ton >
< / ItemTemplate >
< / asp:TemplateField >
< / >
< AlternatingRowStyle BackColor = 白色 ForeColor = #284775 />
< EditRowStyle BackColor = #999999 />
< FooterStyle BackColor = #5D7B9D Font-Bold = True ForeColor = 白色 />
< HeaderStyle BackColor = #5D7B9D Font-Bold = True ForeColor = 白色 />
< PagerStyle BackColor = #284775 ForeColor = 白色 Horizo​​ntalAlign = 中心 />
< RowStyle BackColor = #F7F6F3 ForeColor = #333333 />
< SelectedRowStyle BackColor = #E2DED6 Font-Bold = True ForeColor = #333333 />
< SortedAscendingCellStyle BackColor = #E9E7E2 />
< SortedAscendingHeaderStyle BackColor = #506C8C />
< SortedDescendingCellStyle BackColor = #FFFDF8 />
< SortedDescendingHeaderStyle BackColor = #6F8DAE />
< / asp:GridView >





sql查询是



 选择 dbo.Document.DocID  [文档ID],dbo.Document.DocName < span class =code-keyword> as  [Document Name],
dbo.Document.Uploadfile as [Uploaded File],dbo。 Document.UploadedBy as [上传者],
dbo.DocType.DocType as [文件类型],dbo.Department.DepType as [部门类型]
来自 dbo.Document left < span class =code-sdkkeyword> join dbo.DocType on dbo.Document.DocTypeID = dbo.DocType.DocTypeID left join
dbo .dpartment上的文档.Document.DepID = dbo.Department.DepID左加入 dbo.Users在dbo.Document.DocID = dbo.Users.UserID





请帮我解决这个问题

解决方案

错误来自你的Sql Query。你永远不应该在列名中给出一个空格。试试这个:

SQL:

 选择 dbo.Document.DocID  as  [DocumentID],dbo.Document.DocName  as  [DocumentName],
dbo.Document.Uploadfile as [UploadedFile],dbo.Document.UploadedBy as [UploadedBy] ,
dbo.DocType.DocType as [DocumentType],dbo.Department.DepType as [ DepartmentType]
来自 dbo.Document left join dbo.DocType dbo.Document.DocTypeID = dbo.DocType.DocTypeID left join
dbo.Department on dbo.Document.DepID = dbo.Department.DepID left < span class =code-keyword> join dbo.Users on dbo.Document.DocID = dbo.Users.UserID



HTML:

 <  < span class =code-leadattribute> asp:gridview     id   =  GridView1    runat   =  server    cellpadding   =  4 < span class =code-attribute>   forecolor   = #333333   >  
GridLines =None >
< >
< asp:templatefield >
< itemtemplate > ;
< asp:linkbutton id = Linkdwnld runat = server CommandArgument =' <% #Eval( UploadFile)%>' CommandName = cmd > 下载< / asp:linkbutton >
< < span class =code-leadattribute> / itemtemplate >
< / asp:templatefield >
< ; / columns > < / asp:gridview >







--Amit


hey all

in m girdview i add linkbutton downlaod when i run follwoing error occur

DataBinding: ''System.Data.DataRowView'' does not contain a property with the name ''Uploadfile''.


girdivew is

 <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
        GridLines="None">
        <Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="Linkdwnld" runat="server"
CommandArgument='<%# Eval("Uploadfile") %>' CommandName="cmd">Download</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>



sql query is

select dbo.Document.DocID as [Document ID],dbo.Document.DocName as [Document Name],
dbo.Document.Uploadfile as [Uploaded File],dbo.Document.UploadedBy as [Uploaded By],
dbo.DocType.DocType as [Document Type],dbo.Department.DepType as [Department Type]
from dbo.Document left join dbo.DocType on dbo.Document.DocTypeID=dbo.DocType.DocTypeID left join 
dbo.Department on dbo.Document.DepID=dbo.Department.DepID left  join dbo.Users on dbo.Document.DocID=dbo.Users.UserID



please help me about this

解决方案

The error is from your Sql Query. You should never give a space in a column name. Try this:
SQL:

select dbo.Document.DocID as [DocumentID],dbo.Document.DocName as [DocumentName],
dbo.Document.Uploadfile as [UploadedFile],dbo.Document.UploadedBy as [UploadedBy],
dbo.DocType.DocType as [DocumentType],dbo.Department.DepType as [DepartmentType]
from dbo.Document left join dbo.DocType on dbo.Document.DocTypeID=dbo.DocType.DocTypeID left join 
dbo.Department on dbo.Document.DepID=dbo.Department.DepID left  join dbo.Users on dbo.Document.DocID=dbo.Users.UserID


HTML:

<asp:gridview id="GridView1" runat="server" cellpadding="4" forecolor="#333333" >
        GridLines="None">
        <columns>
<asp:templatefield>
<itemtemplate>
<asp:linkbutton id="Linkdwnld" runat="server" CommandArgument='<%# Eval("UploadFile") %>' CommandName="cmd">Download</asp:linkbutton>
</itemtemplate>
</asp:templatefield>
</columns></asp:gridview>




--Amit


这篇关于gridview问题..我添加下载链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆