TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chevy Mark Sunderland
NA
188
166.7k
DropDownList is empty.
May 3 2012 9:45 AM
Hello there.
First of all I must say that I am a newbie when it comes to net.
Here is my problem.
In this net code I don't have error but the
`DropDownList ddlPages` is empty.
If you have link for similar task, please give it me.
Your help would be very appreciated.
thanks for your time and hints.
protected void GridView1_DataBound(Object sender, EventArgs e)
{
GridViewRow gvrPager = GridView1.BottomPagerRow;
if (gvrPager == null) return;
// get your controls from the gridview
DropDownList ddlPages = (DropDownList)gvrPager.Cells[0].FindControl("ddlPages");
Label lblPageCount = (Label)gvrPager.Cells[0].FindControl("lblPageCount");
if (ddlPages != null)
{
// populate pager
for (int i = 0; i < GridView1.PageCount; i++)
{
int intPageNumber = i + 1;
ListItem lstItem = new ListItem(intPageNumber.ToString());
if (i == GridView1.PageIndex)
lstItem.Selected = true;
ddlPages.Items.Add(lstItem);
}
}
// populate page count
if (lblPageCount != null)
lblPageCount.Text = GridView1.PageCount.ToString();
}
protected void ddlPages_SelectedIndexChanged(Object sender, EventArgs e)
{
GridViewRow gvrPager = GridView1.BottomPagerRow;
DropDownList ddlPages = (DropDownList)gvrPager.Cells[0].FindControl("ddlPages");
GridView1.PageIndex = ddlPages.SelectedIndex;
// a method to populate your grid
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
}
protected void Paginate(object sender, CommandEventArgs e)
{
// get the current page selected
int intCurIndex = GridView1.PageIndex;
switch (e.CommandArgument.ToString().ToLower())
{
case "first":
GridView1.PageIndex = 0;
break;
case "prev":
GridView1.PageIndex = intCurIndex - 1;
break;
case "next":
GridView1.PageIndex = intCurIndex + 1;
break;
case "last":
GridView1.PageIndex = GridView1.PageCount;
break;
}
// popultate the gridview control
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
}
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnMySQL %>"
ProviderName="<%$ ConnectionStrings:ConnMySQL.ProviderName %>"
SelectCommand="SELECT * FROM tbl_1 "
DataSourceMode="DataSet"
OldValuesParameterFormatString="{0}"
OnSelected="SqlDataSource1_Selected" >
<pagerTemplate>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="/Images/bot_back_doble.gif"
CommandArgument="First" CommandName="Page" />
<asp:ImageButton ID="ImageButton2" runat="server"
ImageUrl="/Images/bot_back.gif"
CommandArgument="Prev" CommandName="Page" />
<asp:DropDownList ID="ddlPages" runat="server"
AutoPostBack="True">
</asp:DropDownList> of <asp:Label ID="lblPageCount"
runat="server"></asp:Label>
<asp:ImageButton ID="ImageButton3" runat="server"
ImageUrl="/Images/bot_next.gif"
CommandArgument="Next" CommandName="Page" />
<asp:ImageButton ID="ImageButton4" runat="server"
ImageUrl="/Images/bot_next_doble.gif"
CommandArgument="Last" CommandName="Page" />
</pagerTemplate>
Reply
Answers (
2
)
How To Retrieve Stored Procedure From Database Using Front End Of Asp.Net Page
Can anyone Explain how to export the data from gridview to MS-Word?