Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > gridview sorting is not working

Reply
Thread Tools

gridview sorting is not working

 
 
Abraham Luna
Guest
Posts: n/a
 
      08-29-2005
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.ConnectionStrin gs["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>


 
Reply With Quote
 
 
 
 
Sachin Saki
Guest
Posts: n/a
 
      08-30-2005
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


"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.ConnectionStrin gs["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>
>
>
>

 
Reply With Quote
 
 
 
 
Abraham Luna
Guest
Posts: n/a
 
      08-30-2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
Gridview sorting event - Gridview Datasource always Null .. why??? jobs ASP .Net Web Controls 2 10-24-2006 07:08 AM
GridView Sorting and paging Not working =?Utf-8?B?TWl0Y2g=?= ASP .Net 0 06-12-2006 09:00 PM
Column sorting not working in GridView Thirsty Traveler ASP .Net 2 05-15-2006 06:59 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57