[Mono-bugs] [Bug 80582][Wis] New - GridView RowCommand Not Fired

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jan 22 14:02:01 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kyklovod at abv.bg.

http://bugzilla.ximian.com/show_bug.cgi?id=80582

--- shadow/80582	2007-01-22 14:02:01.000000000 -0500
+++ shadow/80582.tmp.17267	2007-01-22 14:02:01.000000000 -0500
@@ -0,0 +1,150 @@
+Bug#: 80582
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Sys.Web
+AssignedTo: gonzalo at ximian.com                            
+ReportedBy: kyklovod at abv.bg               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: GridView RowCommand Not Fired 
+
+When use GridView control RowCommand events not fired 
+
+Sample Representation:
+
+<%@ Page language="C#" EnableViewState="false" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<script runat="server">
+
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        aa();
+    }
+
+    protected void aa()
+    {
+        System.Collections.ArrayList base1 = new ArrayList();
+        base1.Add(1);
+        base1.Add(2);
+
+        CustomersGridView.DataSource = base1;
+        CustomersGridView.DataBind();
+    }
+    
+  void CustomersGridView_RowCommand(Object sender, 
+GridViewCommandEventArgs e)
+  {
+    // If multiple buttons are used in a GridView control, use the
+    // CommandName property to determine which button was clicked.
+      Response.Write("bbbbbbbbbbbbbbbbbbbbbbbbb");
+    if(e.CommandName=="Add")
+    {
+      // Convert the row index stored in the CommandArgument
+      // property to an Integer.
+      int index = Convert.ToInt32(e.CommandArgument);
+            
+      // Retrieve the row that contains the button clicked 
+      // by the user from the Rows collection.
+      GridViewRow row = CustomersGridView.Rows[index];
+            
+      // Create a new ListItem object for the customer in the row.     
+      ListItem item = new ListItem();
+      item.Text = Server.HtmlDecode(row.Cells[2].Text);
+            
+      // If the customer is not already in the ListBox, add the ListItem 
+      // object to the Items collection of the ListBox control. 
+      if (!CustomersListBox.Items.Contains(item))
+      {
+        CustomersListBox.Items.Add("aa");
+      }           
+    }
+  }
+
+  void CustomersGridView_RowCreated(Object sender, GridViewRowEventArgs e)
+  {
+    
+    // The GridViewCommandEventArgs class does not contain a 
+    // property that indicates which row's command button was
+    // clicked. To identify which row's button was clicked, use 
+    // the button's CommandArgument property by setting it to the 
+    // row's index.
+    if(e.Row.RowType == DataControlRowType.DataRow)
+    {
+      // Retrieve the LinkButton control from the first column.
+       // Response.Write(e.Row.Cells[0].Controls[0].GetType().ToString() 
++"\n");
+      Button addButton = (Button)e.Row.Cells[0].Controls[0];
+        //DataControlField addButton = (DataControlField)e.Row.Cells
+[0].Controls[0];
+      
+      // Set the LinkButton's CommandArgument property with the
+      // row's index.
+      addButton.CommandArgument = e.Row.RowIndex.ToString();
+    }
+
+  }
+    
+</script>
+
+<html  >
+  <head id="Head1" runat="server" enableviewstate="false">
+    <title>GridView RowCommand Example</title>
+</head>
+<body>
+    <form id="form1" runat="server" enableviewstate="false">
+        
+      <h3>GridView RowCommand Example</h3>
+            
+      <table width="100%">         
+        <tr>                
+          <td style="width:50%">
+                    
+            <asp:gridview id="CustomersGridView"  EnableViewState="false"
+              
+              allowpaging="true" 
+              autogeneratecolumns="false"
+              onrowcommand="CustomersGridView_RowCommand"
+              onrowcreated="CustomersGridView_RowCreated"  
+              runat="server">
+                
+              <columns>
+                <asp:buttonfield buttontype="Link" 
+                  commandname="Add"
+                  text="Add"/>
+                <asp:boundfield  
+                  headertext="Customer ID"/>
+                <asp:boundfield 
+                  headertext="Company Name"/> 
+                <asp:boundfield 
+                  headertext="City"/>          
+              </columns>
+                
+            </asp:gridview>
+                    
+          </td>
+                    
+          <td style="vertical-align:top; width:50%">
+                    
+            Customers: <br/>
+            <asp:listbox id="CustomersListBox"
+              runat="server"/> 
+                    
+          </td>  
+        </tr>      
+      </table>
+            
+      
+            
+    </form>
+  </body>
+</html>


More information about the mono-bugs mailing list