OnRowCommand& OnSelectedIndexChanging [英] OnRowCommand & OnSelectedIndexChanging

查看:54
本文介绍了OnRowCommand& OnSelectedIndexChanging的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此编辑,取消和更新:

< asp:GridView ID =   GridView1 
runat = server
DataKeyNames = id
AutoGenerateEditButton = True
AutoGenerateDeleteButton = True
OnRowCancelingEdit = Gridview1_OnRowCancelingEdit
OnRowEditing = Gridview1_OnRowEditing
OnRowUpdating = GridView1_OnRowUpdating
/>





这限制了pag e尺寸为50,其余部分标签:

< asp:GridView ID =  < span class =code-string> GridView1 
runat = server
AllowPaging = True
PageSize = 50
/>





按升序和降序排序只需点击列标签:

< asp:GridView ID =   GridView1 
runat = < span class =code-string> server
DataSourceID = postData
AllowSorting = True />







这是做什么用的?你需要和你一起运行什么?

 <   asp:GridView     ID   =   gvRowCommand    runat  < span class =code-keyword> =  & uot; server  

OnRowCommand = gvRowCommand_RowCommand >
< / asp:GridView >







这是做什么的?你需要和你一起运行什么?

 <   asp:GridView     ID   =   GridView1    runat  < span class =code-keyword> =  server  
< span class =code-attribute>
OnSelectedIndexChanging = GridView1_SelectedIndexChanging >
< / asp:GridView >

解决方案

第一个问题的答案



来自MSDN:

Quote:

在GridView控件中单击按钮时发生

(当编辑,取消,更新等任何按钮时触发意外)



要知道哪个ButtonClick触发了事件,需要设置CommandName为按钮并查看活动内部。



EX:



if(e.CommandName ==编辑)

{

//编辑代码。



}



第二名:



引用:

发生当单击一行的选择按钮时,但在GridView控件处理选择操作之后。





当需要检索Gridview Selected Row值时,它非常有用selectedIndex。



参考MSDN



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand(v = vs.110)。 aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview .selectedindexchanged(v = vs.110).aspx [ ^ ]



并按照一些例子。


This Edits, Cancels and Updates:

<asp:GridView ID="GridView1"
        runat="server"
        DataKeyNames="id"
        AutoGenerateEditButton="True"
        AutoGenerateDeleteButton="True"
        OnRowCancelingEdit="Gridview1_OnRowCancelingEdit"
        OnRowEditing="Gridview1_OnRowEditing" 
        OnRowUpdating="GridView1_OnRowUpdating
        />



This limits page size to 50 and has tabs for the rest:

<asp:GridView ID="GridView1"
   runat="server"
   AllowPaging="True"
   PageSize="50"
   />



This sorts by ascending and descending just click to column label:

<asp:GridView ID="GridView1"
   runat="server"
   DataSourceID="postData"
   AllowSorting="True"/>




What does this do? What do you need to run in conjunction with?

<asp:GridView ID="gvRowCommand" runat=&uot;server"

    OnRowCommand="gvRowCommand_RowCommand">
    </asp:GridView>




What does this do? What do you need to run in conjunction with?

<asp:GridView ID="GridView1" runat="server"

    OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
    </asp:GridView>

解决方案

Answer for First Question

From MSDN :

Quote:

Occurs when a button is clicked in a GridView control

(Means fires when any of the Buttons like Edit, Cancel,Update etc.)

And to know which ButtonClick has triggered the event, need to set the CommandName for the Button and check inside the Event.

EX:

if(e.CommandName=="Edit")
{
//Code For Edit.

}

Second :

Quote:

Occurs when a row's Select button is clicked, but after the GridView control handles the select operation.



Its useful when need to retrieve the Gridview Selected Row value with the selectedIndex.

Refer MSDN

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand(v=vs.110).aspx[^]

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanged(v=vs.110).aspx[^]

And follow some examples.


这篇关于OnRowCommand&amp; OnSelectedIndexChanging的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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