Hi,
daRDK.Dispose();
connRDK.Close();
connRDK.Dispose();
Use Try Catch Block and Place this 3 lines in the Finally Block.
Regards,
Sachin Saki
..NET Developer : Capgemini - INDIA
[quoted text, click to view] "Abraham Luna" wrote:
> can anyone tell me why this code is not working, i've been following the
> tutorials but i can't get it to work:
>
> <script language="c#" runat="server">
>
> void Page_Load (Object Sender, EventArgs E)
> {
> if (!Page.IsPostBack)
> {
> BindData(0);
> }
> }
>
> void btnRefresh_Click(Object Sender, EventArgs E)
> {
> BindData(0);
> }
>
> void gvCustomers_PageIndexChanging(Object Sender, GridViewPageEventArgs E)
> {
> BindData(E.NewPageIndex);
> E.Cancel = true;
> }
>
> void BindData(int intPageIndex)
> {
> lblSQL.Text = "SELECT [CusId], [Name], [Addr1] + '<br>' + [City] + ', ' +
> [State] + ' ' + [Post] AS Address, [PhoneWork], [Contact], [EmailWork] FROM
> [COCUS]";
> SqlConnection connRDK = new
> SqlConnection(ConfigurationManager.ConnectionStrings["TestConnection"].ToString());
> SqlDataAdapter daRDK = new SqlDataAdapter(lblSQL.Text, connRDK);
> DataTable dtCustomers = new DataTable();
> daRDK.Fill(dtCustomers);
> daRDK.Dispose();
> connRDK.Close();
> connRDK.Dispose();
> gvCustomers.DataSource = dtCustomers;
> gvCustomers.DataBind();
> gvCustomers.PageIndex = intPageIndex;
> gvCustomers.PageSize = Convert.ToInt32(ddlRPP.SelectedItem.Value);
> lblTotal.Text = dtCustomers.Rows.Count.ToString();
> lblPageIndex.Text = gvCustomers.PageIndex.ToString();
> }
>
> </script>
>
>
so sorry, maybe it would help if i explained what isnt working. everything
works except the gvCustomers_PageIndexChanging
it doesnt seem to call binddata
does anyone have an advanced gridview sample that uses: paging, sorting, and
filtering using webcontrols