using System;
using System.Text;
using System.Web.UI;

public partial class GridView : Page
{
    protected void gvwCustomers_SelectedIndexChanged(object sender, EventArgs e)
    {
       StringBuilder info = new StringBuilder();
       info.AppendFormat("Przeglądasz rekord {0} z {1} (SelectedIndex)<br />",
          gvwCustomers.SelectedIndex.ToString(), gvwCustomers.Rows.Count.ToString());
       info.AppendFormat("Przeglądasz rekord {0} z {1} (DataKeys)<br />",
          gvwCustomers.SelectedIndex.ToString(), gvwCustomers.DataKeys.Count);
       info.AppendFormat("Przeglądasz stronę {0} of {1} (PageCount)<br />",
          gvwCustomers.PageIndex.ToString(), gvwCustomers.PageCount.ToString());

       info.AppendFormat("<p>Używając SelectedRow, Email Address= {0}<br />", gvwCustomers.SelectedRow.Cells[4].Text);

       info.Append("Używając SelectedDataKey<br />");

       for (int i = 0; i < gvwCustomers.DataKeyNames.Length; i++)
       {
          info.AppendFormat("{0} : {1}<br />", gvwCustomers.DataKeyNames[i], gvwCustomers.SelectedDataKey.Values[i]);
       }

       info.AppendFormat("Wybrana wartość: {0}", gvwCustomers.SelectedValue.ToString());

       lblInfo.Text = info.ToString();
    }
}
