开发者

Asp.net table display using grid view and deleting one row in the website

I am displaying a table in a grid view in a asp.net webpage. I want the user to select one row in the website and delete it. How can I do that. I have a delete button in the same page, where I will do code behind to drop the row in the database. But my problem is how can user select one row in the table .

 <asp:GridView ID="GridView1" runat="server" CssCl开发者_运维问答ass="style29">
     <Columns>
         <asp:TemplateField HeaderText="Send Message to Group">
         <ItemTemplate>
             <asp:LinkButton ID="LinkButton2" runat="server" 
             PostBackUrl='<%# Eval("GroupName", "SendMessage.aspx?GroupName={0}") %>' 
             Text='Send Message'></asp:LinkButton>
        </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Is it possible to do without a check box? Or can I add a delete image to the table in a separate column and on clicking the button the row will be deleted.


You should add:

<asp:CommandField ShowSelectButton="True"/>

on your gridview.


Use ICallbackEventHandler to trigger an action on the server.

But my problem is how can user select one row in the table .

this code adds a Select button:

<asp:CommandField ShowSelectButton="True" />

Now your problem is only to get the server to execute some piece of code, do that using ICallbackEventHandler or Ajax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜