关于数据表的信息 [英] info about datatable

查看:56
本文介绍了关于数据表的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们能否将数据绑定到gridview而不获取datateble而不将其转换为datarowview?

当我们使用datarowview和datatable的datarow对象时?

我看过的datarowview是dataview的自定义视图

数据视图的定制视图是什么意思?

这是我将container.dataitem对象转换为datarowview的代码

Can we bind data to gridview from retrieving datateble without converting it to datarowview?

When we use datarowview and datarow object of datatable?

I read the datarowview is the customized view of dataview

What is meaning of customized view of dataview?

Here is code in which i cast container.dataitem object to datarowview

<pre lang="xml"><asp:DataList ID="FreindRequestList" runat="server" Width="100%" RepeatColumns="100"
               OnItemCommand="FreindRequestList_ItemCommand" style="border-right: red 1px solid; border-top: red 1px solid; border-left: red 1px solid; color: #fdfafc; border-bottom: red 1px solid; background-color: #ffffda" ForeColor="#FFFFC0" OnSelectedIndexChanged="FreindRequestList_SelectedIndexChanged">
               <ItemTemplate>
                   <table border="0" cellpadding="2" cellspacing="2" align="center" style="background-color: #f5f5f5">
                       <tr>
                           <td align="center" valign="top">
                               <a href=''<%#getHREF(Container.DataItem)%>''>
                                   <input type="hidden" id="hiddenId" value=''<%# DataBinder.Eval(Container.DataItem, "Id") %>''
                                       runat="server" name="hiddenId" />
                                   <img src=''<%# getSRC(Container.DataItem) %>'' align="middle" border="0" width="80px">
                                   <br />
                                   <asp:Button ID="AcceptButton" runat="server" ToolTip="Accept" Text="Accept" CommandName="Accept" /><br />
                                   <asp:Button ID="Deny" runat="server" ToolTip="Deny" Text="Deny" CommandName="Deny" />
                               </a>&nbsp;
                           </td>
                       </tr>
                   </table>
               </ItemTemplate>
           </asp:DataList>













public string getSRC(object imgSRC)
   {
       DataRowView dRView = (DataRowView)imgSRC;
       string ImageName = dRView["ImageName"].ToString();
       if (ImageName == "NoImage")
       {
           return ResolveUrl(@"~/UserImage/missing.jpg");
       }
       else
       {
           return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString());
       }



不明白为什么在上面的代码中将imgSrc转换为datarowview

我不了解datarowview

[edit]降低音量... [/edit]



not undestand why in above code to cast imgSrc to datarowview

i not understand about datarowview

[edit]Apply Volume Down...[/edit]

推荐答案

1)您不需要转换为DataRowView. datarowview在内部创建,并由控件使用.

2)DataTable仅具有DataRows的集合而没有DataRowViews

3)您在哪里读到的?

4)绿色是什么颜色?看看这个问题有多小意义?

[在OP发布附加信息后添加]

如#1所述,DataRowView由控件内部使用.由于该控件不知道绑定到它的集合的真正含义,只是它支持IEnumerable接口,因此它必须将集合中的项目存储在它知道的对象中,并且可以用于呈现和操作, DataRowView.由于集合可以包含任何内容,因此必须将其表示为Object,这是.NET中所有内容的基类.因此,必须进行强制转换才能将Object转换为DataRowView.
1) You don''t need to convert to DataRowView. A datarowview is created internally and is used by the control.

2) A DataTable doesn''t have DataRowViews only a collection of DataRows

3) Where have you read this?

4) What is the color of green? See how little sense the question makes?

[Added after OP posted additional information]

As stated in #1 the DataRowView is used internally by the control. Since the control doesn''t know what the collection that was bound to it really is, only that it supports the IEnumerable interface, it must store the items in the collection in an object it knows about and can use for the rendering and manipulation, DataRowView. Since the collection can contain anything it must be represented as Object, the base class of everything in .NET. The cast is thus necessary to convert Object to DataRowView.


这篇关于关于数据表的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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