473,395 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

prob in gridview at dropdown list select event

following is the code i write
Expand|Select|Wrap|Line Numbers
  1.  
  2. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  3.    {
  4.          SqlCommand com1 = new SqlCommand("quot;select sno,adv,city from adv1 where categry=@b",con);
  5.          com1.Parameters.AddWithValue("@b", DropDownList1.Text);
  6.          con.Open();
  7.          GridView1.DataSource = com1.ExecuteReader();
  8.          con.Close();
  9.          GridView1.DataBind();
  10. }
  11.  
and under grid view i write following
Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  2.       {
  3.             GridView1.PageIndex = e.NewPageIndex;
  4.             GridView1.AllowPaging = true;
  5.       }
it gives error"The data source does not support server-side data paging."
anyone can help?
Feb 16 '11 #1
2 2801
Expand|Select|Wrap|Line Numbers
  1. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  2.    {
  3.          SqlCommand com1 = new SqlCommand("quot;select sno,adv,city from adv1 where categry=@b",con);
  4.          com1.Parameters.AddWithValue("@b", DropDownList1.Text);
  5.          con.Open();
  6.          GridView1.DataSource = com1.ExecuteReader();
  7.          con.Close();
  8.          GridView1.DataBind();
  9. }

This coding is wrong
--------------------------------------

coding is

Expand|Select|Wrap|Line Numbers
  1. SqlCommand com1 = new SqlCommand("quot;select sno,adv,city from adv1 where categry=@b",con);
  2.          com1.Parameters.AddWithValue("@b", DropDownList1.Text);
  3.  
  4.          SqlDataAdapter adp = new SqlDataAdapter(com1);
  5.          DataSet ds = new DataSet();
  6.          adp.Fill(ds);
  7.          GridView1.DataSource = ds;
  8.          GridView1.DataBind();
Feb 17 '11 #2
Frinavale
9,735 Expert Mod 8TB
Your code is not necessarily "wrong"...it's just that when you use the ExecuteReader it returns data from the database and that data is not pageable unless you put it into a control that is (Like a DataView for example).

Or you could do what bhuvaneswaran suggested and use a dataset instead :)
Feb 17 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
0
by: Karl | last post by:
Hi all, I want to do some datasource refresh when my combobox dropdown list closes sup. Which event should I call? Thanks, Karl
4
by: anonymous | last post by:
Hi Folks, I have a form with two Dropdown list boxes, which get loaded with data from Database. DropDownList1 gets data from Table1 and DropDownList2 gets data from Table2 Table1 has a...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
1
by: Jack | last post by:
Hello, I have a dropdown list on a user control and the AutoPostBack property is set to True. I want to use the SelectedIndexChanged event to populate some text boxes based on what the user...
3
by: Advertis | last post by:
Is there a way to populate a dropdown in a GridView with the next x years? I am using a GridView to display data from a SQL table One of the fields is a Year. I want to have the dropdown list not...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
1
by: narasima | last post by:
Hi All, I am Narasimha. I want to be disply the dropdown list ,list box,check box in gridview control.and when your select in dropdown list option 2 two records are update when ever you...
0
by: progman417 | last post by:
I have a gridview with a dropdown list in an EditItemTemplate. I haven't set a width for the columns, so that they dynamically size according to the data displayed. When it goes into edit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.