title: datalist editing is not working?
body: <p>I am working on data list item editing concept,i think i am done all code correct but when click on edit button blank page is showing please see this problem and send any bugs and salvation suggestion please  </p>
  
  <p>HTML CODE
      
      </p>
  
  <pre><code>    &lt;asp:DataList ID="DataList1" runat="server" DataKeyField="outlet_id" OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand" RepeatColumns="2"&gt; 
          &lt;ItemTemplate&gt;
          &lt;asp:Label ID="Label1" runat="server" Text='&lt;%#Eval("outlet_id") %&gt;' &gt;&lt;/asp:Label&gt;
              &lt;asp:Label ID="lbl" runat="server" Text='&lt;%#Eval("company_name") %&gt;' &gt;&lt;/asp:Label&gt;
              &lt;asp:Button ID="edit" runat="server" Text="Edit" CommandName="edit"  /&gt;
              &lt;asp:Button ID="delete" runat="server" Text="Del" CommandName="del" /&gt;
          &lt;/ItemTemplate&gt;
          &lt;EditItemTemplate&gt;
          id&lt;asp:TextBox ID="id" runat="server" Text='&lt;%#Eval("outlet_id") %&gt;'&gt;&lt;/asp:TextBox&gt; 
          name&lt;asp:TextBox ID="name" runat="server" Text='&lt;%#Eval("company_name") %&gt;'  &gt;&lt;/asp:TextBox&gt;
              &lt;asp:Button ID="Button2" runat="server" CommandName="update" Text="update" /&gt;
              &lt;asp:Button ID="Button3" runat="server" CommandName="cancel" Text="Cancel" /&gt;
          &lt;/EditItemTemplate&gt;
      &lt;/asp:DataList&gt;
  
  
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>and c# code here bellow</p>
  
  <p>page load</p>
  
  <pre><code>  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          bind();
      }
  
  }
  </code></pre>
  
  <p>Edit command code</p>
  
  <pre><code>protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
      {
          DataList1.EditItemIndex = e.Item.ItemIndex;
          DataList1.DataBind();
  
      }
  </code></pre>
  
  <p>cancel command code</p>
  
  <pre><code>protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
  {
      DataList1.EditItemIndex = -1;
      DataList1.DataBind();
  }
  </code></pre>
  
  <p>this is datalist binding </p>
  
  <pre><code>protected void bind()
  {
      SqlConnection con = new SqlConnection(strconnection);
      con.Open();
      string qry = "select top 10 outlet_id,company_name from outlet_table ";
      SqlDataAdapter Da = new SqlDataAdapter(qry, con);
      DataSet ds = new DataSet();
      Da.Fill(ds, "outlet");
      DataList1.DataSource = ds;
      DataList1.DataBind();
  }
  </code></pre>
  
  <p>this is a Client side html data showing after click on edit button </p>
  
  <pre><code>&lt;body&gt;
  &lt;form name="form1" method="post" action="Demo.aspx" id="form1"&gt;
  &lt;div&gt;
  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="zVlNF4jkNpf9ZmIBtYaHSdSPa9l8zKVA4H0JXxnhqVytzfrbVWUuOuY8004hXYRY8KuBKqPKgV3kS4RQBegrJQ5LErL3VdV9TeluNoxAZLtDu0/62xR8Ij/jD638pPKb"&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
  
      &lt;input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value=""&gt;
  &lt;/div&gt;
  
  
  
  
  
      &lt;/form&gt;
  
  
  &lt;/body&gt;
  </code></pre>