设置DetailsView控件为GridView控件的选定行 [英] Set DetailsView as selected row of GridView

查看:212
本文介绍了设置DetailsView控件为GridView控件的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的GridView / DetailsView控件的页面。我有一个显示了一堆行,当行被选中它使用一个DetailsView允许插入/更新的网格。

我的问题是什么是链接这些的最佳途径?我不想再伸手到Web服务,我需要的是所选网格视图行中的数据。我基本上有相同DataObjectTypeName2个独立的数据源,所述第一数据源检索数据,另做CRUD。

什么是选定的网格视图行转移到详细信息视图的最佳方式?难道我将不得不manualy处理插入/更新事件和调用数据源代码呢?

有没有办法来链接这两个让他们使用相同的数据源?

 < ASP:GridView控件ID =gvDetails=服务器的DataKeyNames =ID,code
                的DataSourceID =odsSearchData>
   <柱体和GT;
        < ASP:BoundField的数据字段=乐华的HeaderText =ASORTEX pression =乐华/>
        < ASP:BoundField的数据字段=rowB中的HeaderText =BSORTEX pression =rowB中/>
        < ASP:BoundField的数据字段=ROWC的HeaderText =CSORTEX pression =ROWC/>    .... code ... < ASP:DetailsView控件ID =dvDetails=服务器的DataKeyNames =ID,code
                的DataSourceID =odsCRUD网格=无DefaultMode =编辑AutoGenerateRows =假
                可见=假宽度=100%>
         <&领域GT;
            < ASP:BoundField的数据字段=乐华的HeaderText =ASORTEX pression =乐华/>
           < ASP:BoundField的数据字段=rowB中的HeaderText =BSORTEX pression =rowB中/>
           < ASP:BoundField的数据字段=ROWC的HeaderText =CSORTEX pression =ROWC/>...


解决方案

标准的方式做这将是有griview的所选项目是一个控制参数,你已经连入DetailsView的ObjectDataSource控件。我可能不会太担心retreiving数据的开销,你已经有了,除非你是在满足人们与你想避免往返到Web服务器不惜一切代价,这样的低速连接的用户。

如果你真的想避免thenyou可以拉出来的数据使用JavaScript / jQuery的GridView控件,然后通过Ajax调用做你的插入/更新。这将需要大量的更多的代码虽然。

I am creating a GridView/DetailsView page. I have a grid that displays a bunch of rows, when a row is selected it uses a DetailsView to allow for Insert/Update.

My question is what is the best way to link these? I do not want to reach out to the web service again, all the data i need is in the selected grid view row. I basically have 2 separate data sources that share the same "DataObjectTypeName", the first data source retrieves the data, and the other to do the CRUD.

What is the best way to transfer the Selected Grid View row to the Details View? Am I going to have to manualy handle the Insert/Update events and call the data source myself?

Is there no way to link these two so they use the same data source ?

  <asp:GridView ID="gvDetails" runat="server" DataKeyNames="ID, Code"
                DataSourceID="odsSearchData" >
   <Columns>
        <asp:BoundField DataField="RowA" HeaderText="A" SortExpression="RowA" />
        <asp:BoundField DataField="RowB" HeaderText="B" SortExpression="RowB" />
        <asp:BoundField DataField="RowC" HeaderText="C" SortExpression="RowC" />



    ....Code...

 <asp:DetailsView ID="dvDetails" runat="server" DataKeyNames="ID, Code"
                DataSourceID="odsCRUD" GridLines="None" DefaultMode="Edit" AutoGenerateRows="false"
                Visible="false" Width="100%">
         <Fields>
            <asp:BoundField DataField="RowA" HeaderText="A" SortExpression="RowA" />
           <asp:BoundField DataField="RowB" HeaderText="B" SortExpression="RowB" />
           <asp:BoundField DataField="RowC" HeaderText="C" SortExpression="RowC" />

...

解决方案

The standard way to do it would be to have the selected item of the griview be a control parameter to the objectdatasource you have wired up to the detailsview. I would probably not worry too much about the overhead of retreiving data that you already have unless you are catering to users with such slow connections that you want to avoid roundtrips to the webserver at all costs.

If you really want to avoid that thenyou could pull the data out of the gridview using javascript/jquery and then do your inserts/updates via ajax calls. It would require lots more coding though.

这篇关于设置DetailsView控件为GridView控件的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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