
你可以增加一个LinkButton列用来获取该行的ID值,将LinKButton的CommandArgument属性和gridview记录的ID(你要记住给数据库的表定义一个标识ID)接着通过queryString传送这个ID值,在另一个页面时你通过查询数据库得到该记录的想要的值
用mvvm模式,在逻辑代码层中根本就不需要知道前台有什么元素。推荐看一下mvvm,会少走很多弯路。
MVVM是Model-View-ViewModel的简写。微软的WPF带来了新的技术体验,如Silverlight、音频、视频、3D、动画……,这导致了软件UI层更加细节化、可定制化。同时,在技术层面,WPF也带来了 诸如Binding、Dependency Property、Routed Events、Command、DataTemplate、ControlTemplate等新特性。MVVM(Model-View-ViewModel)框架的由来便是MVP(Model-View-Presenter)模式与WPF结合的应用方式时发展演变过来的一种新型架构框架。它立足于原有MVP框架并且把WPF的新特性糅合进去,以应对客户日益复杂的需求变化。
若EF是采用代码优先生成数据库的话则需要修改EF中对应的Model的代码,即info中新增一列即可,不需要改动其他内容了;
若EF是采用根据现有数据库生成的话,需要在数据库对应表中添加一列,再重新生成EF的代码即可。
参照如下代码改下html样式就好 ,不明白的留言我
<table width="100%">
<tr>
<td style="text-align:right">
第<asp:Label id="lblPageIndex" runat="server" text='<%# ((GridView)ContainerParentParent)PageIndex + 1 %>' />页
共/<asp:Label id="lblPageCount" runat="server" text='<%# ((GridView)ContainerParentParent)PageCount %>' />页
<asp:linkbutton id="btnFirst" runat="server" causesvalidation="False" commandargument="First" commandname="Page" text="首页" />
<asp:linkbutton id="btnPrev" runat="server" causesvalidation="False" commandargument="Prev" commandname="Page" text="上一页" />
<asp:linkbutton id="btnNext" runat="server" causesvalidation="False" commandargument="Next" commandname="Page" text="下一页" />
<asp:linkbutton id="btnLast" runat="server" causesvalidation="False" commandargument="Last" commandname="Page" text="尾页" />
<asp:textbox id="txtNewPageIndex" runat="server" width="20px" text='<%# ((GridView)ContainerParentParent)PageIndex + 1 %>' />
<asp:linkbutton id="btnGo" runat="server" causesvalidation="False" commandargument="-1" commandname="Page" text="GO" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
</td>
</tr>
</table>
</PagerTemplate>
protected void grdvSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//thisgrdvSearchResultPageIndex = eNewPageIndex;
////thisDataBind();
DataTable aaa = new DataTable();
aaa = (DataTable)ViewState["TableForAllSelect"];
grdvSearchResultDataSource = aaa;
grdvSearchResultDataBind();
grdvSearchResultVisible = true;
GridView theGrid = sender as GridView; // refer to the GridView
int newPageIndex = 0;
if (-2 == eNewPageIndex)
{ // when click the "GO" Button
TextBox txtNewPageIndex = null;
//GridViewRow pagerRow = theGridControls[0]Controls[theGridControls[0]ControlsCount - 1] as GridViewRow; // refer to PagerTemplate
GridViewRow pagerRow = theGridBottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
//updated at 2006年6月21日3:15:33
if (null != pagerRow)
{
txtNewPageIndex = pagerRowFindControl("txtNewPageIndex") as TextBox; // refer to the TextBox with the NewPageIndex value
}
if (null != txtNewPageIndex)
{
newPageIndex = intParse(txtNewPageIndexText) - 1; // get the NewPageIndex
}
}
else
{ // when click the first, last, previous and next Button
newPageIndex = eNewPageIndex;
}
// check to prevent form the NewPageIndex out of the range
newPageIndex = newPageIndex < 0 0 : newPageIndex;
newPageIndex = newPageIndex >= theGridPageCount theGridPageCount - 1 : newPageIndex;
// specify the NewPageIndex
theGridPageIndex = newPageIndex;
}
var e = MainGrid.getSelectionModel().selection.record;e.set(&#39;depid&#39;, &#39;10000&#39;);e.set(&#39;depname&#39;, &#39;总部&#39;);var depid = e.get(&#39;depid&#39;);var depname = e.get(&#39;depname&#39;);这个record其实就是一个json对象
以上就是关于如何获取 Grid中选中的值全部的内容,包括:如何获取 Grid中选中的值、wpf 怎么获取grid中指定行数中的所有子元素、采用EF开发数据库,前台使用jqGrid直接获取数据。现在问题,如果有多表联合查询如何解决等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)