Tuesday, June 18, 2013

Data List in ASP.NET

Data List
           
 1) Create one page – datalist.aspx
            2)  Insert one table
            3)  Place “Datalist“ from toolbox
            4) > click Edit Template
            5)  Insert Table ( in the Left side)
            6) Insert HTML "Image" from tool box
            7)  Select “DataList” – right Click - properties

                                                Repeat columns   -   4 
                                                 Repeat direction  -   horizontal
8)Go to  “HTML” source.
Stage-2

7)       Insert “Edit” & “Delete” button by type the code
                           <td><asp:LinkButton ID="LinkButton1" runat="server"
              CommandArgument='<%#Eval("user_name")%>'     
                       CommandName="Editme">Editme</asp:LinkButton></td>                 
8)       NB: When we press “Editme ” button we are passing the “Command Argument”.

Stage-3

9)       Select “DataList” – Right Click – Events  - Double Click “ITEMCOMMAND”
10)   We are catching the values using ITEM COMMAND

                     protected void Datalist1_ItemCommand(object source, RepeaterCommandEventArgs e)
                {
                  if (e.CommandName == "Editme")
                  {
                     String U_name = e.CommandArgument.ToString();
                                        }

           }

No comments:

Post a Comment