Subscribe Now!

Enter your email address:

Monday, January 3, 2011

Popping up Message Boxes In Grid View


<form id="form1" runat="server">
  <asp:SqlDataSource runat="server" 
    ID="SqlDataSource2" 
    ConnectionString="..."
    SelectCommand="SELECT [CategoryID], [CategoryName], 
                  [Description] FROM [Categories]"
    DeleteCommand="Delete from categories where categoryID=@categoryID">
    <DeleteParameters>
      <asp:Parameter Name=categoryID Type=int16 />
    </DeleteParameters>
  </asp:SqlDataSource>
  
  <asp:GridView ID="GridView2" runat=server AutoGenerateColumns="False"
  datasourceid="SqlDataSource2" DataKeyNames=CategoryID>
  <Columns>
    <asp:BoundField DataField="CategoryID" 
      HeaderText="ID"
      readonly=true/>
      <asp:BoundField DataField="CategoryName" HeaderText="Name"/> 
      <asp:BoundField DataField="Description" HeaderText="Description" />
      <asp:TemplateField HeaderText="Delete">
        <ItemTemplate>
          <asp:Button ID="deleteButton" runat="server" 
            CommandName="Delete" Text="Delete"
            OnClientClick="return confirm('Are you sure you want to delete this record?');" />
        </ItemTemplate>
      </asp:TemplateField>
  </Columns>
  </asp:GridView>

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...