|
 Hey for eg:You have got a table(say 'dt') retrieved from the database...
Now bind it to PagedDataSource.
public partial class Default4 : System.Web.UI.Page <br />
<br />
{<br />
<br />
<br />
DataTable dt = null;<br />
protected int currentpage = 0;<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
<br />
{<br />
<br />
#region Datalist binding with PagedDataSource<br />
<br />
<br />
PagedDataSource ps = new PagedDataSource();<br />
ps.DataSource = dt.DefaultView;<br />
ps.AllowPaging = true;<br />
<br />
ps.PageSize = 2;<br />
<br />
if (Request.QueryString["Page"] != null)<br />
{<br />
currentpage = Convert.ToInt32(Request.QueryString["Page"]);<br />
<br />
}<br />
else<br />
{<br />
currentpage = 1;<br />
}<br />
<br />
ps.CurrentPageIndex = currentpage - 1;<br />
Label1.Text = "Page:" + currentpage;<br />
<br />
if(!ps.IsFirstPage)<br />
{<br />
PrevLink.NavigateUrl = Request.CurrentExecutionFilePath +"?Page=" +(currentpage - 1);<br />
}<br />
<br />
if (!ps.IsLastPage)<br />
{<br />
NextLink.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" +(currentpage + 1);<br />
}<br />
<br />
<br />
<br />
<br />
DataList1.DataSource = ps;<br />
DataList1.DataBind();<br />
<br />
<br />
#endregion<br />
<br />
<br />
}
In the above example prevlink and nextLink are the Hyperlinks in your page
Koushik
|
|
|
|
|
thanx! i'll try it it in the evening and i'll post a result here. thanx!
--
"Success is simple. Do what's right, the right way, at the right time."
best regards,
tradakad
|
|
|
|
|
hi
i have some hyperlinks that show news title, i want when user click on hyperlink redirect to another page and pass some values to that page, but how to do ?
Note : i want when user click on hyperlink, i retrieve id of it and pass to another page, but in *.aspx how to retrieve ID from database and pass to another page by hyperlink ?
|
|
|
|
|
Hi,
You should write your logic of retrieving ID from the database in the "Page_Load" event and set the hyperlink's navigatUrl property.
hyperlink.NavigateUrl = "targetpage.aspx?ID" + ID.ToString();
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Also refer Urlencode functionality.
Regards,
Arun Kumar.A
|
|
|
|
|
Arun.Immanuel wrote: Also refer Urlencode functionality
Also refer Urlencode functionality
thanks .. my problem was solved, but how to use Urlencode functionality ??
plz give an example. thanks
|
|
|
|
|
hyperlink.NavigateUrl = "targetpage.aspx?ID" + Server.UrlEncode(ID.ToString());
Generally , "&" is the delimiter for querystrings.
So, if ID="Good&Bad" , then while retrieving U will get "Good" alone.
hope, I have explained it clearly.
Regards,
Arun Kumar.A
|
|
|
|
|
hi,i have one doubt regarding page class methods.my doubt is when to use RegisterStartupScript() and RegisterClientScriptBlock() methods.what is the major difference between the two methods?.please give suggestions for where those best suited.
|
|
|
|
|
I Don't know much about this two except
The RegisterClientScriptBlock method adds a script block to the top of the rendered page.
Whereas
The script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised.
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
SqlConnection myConnection =
new SqlConnection(connstring );
SqlDataAdapter myAdapter =
new SqlDataAdapter(
"SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice FROM Products",
myConnection);
//Fill the DataSet
DataSet ds = new DataSet();
myAdapter.Fill(ds,"Products");
//DataBind the Repeater
// MyRepeater.DataSource = ds.Tables["Products"].DefaultView;
// MyRepeater.DataBind();
// Populate the repeater control with the Items DataSet
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize =10;
objPds.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
+ objPds.PageCount.ToString();
// Disable Prev or Next buttons if necessary
cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage;
MyRepeater.DataSource=objPds;
MyRepeater.DataBind();
this is my code what is the use of( ds.Tables[0].DefaultView)this;
can u explain me??
regards
saravanan
|
|
|
|
|
I tmeans that the first table in the dataset is to be attached to the datasource of the control...DefaultView property returns a DataView you can use to sort, filter, and search a DataTable...
for eg... ds.Tables[0].DefaultView.RowFilter = "city='New York'"
Koushik
|
|
|
|
|
ds.Tables[0].DefaultView referes to opening view or customized view of the table that may include a filtered view, or a cursor position.
|
|
|
|
|
how to make a control visible and hidden when i click a button
thks
|
|
|
|
|
Hi
Takae look at it
<br />
document.getElementById(groupid).style.display=="none"<br />
document.getElementById(groupid).style.display="block";<br />
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
Hi,
To hide the Contorl use the following code in javascript:
document.getElementById("controlName").style.visibility = "hidden";
To Visible the control use the following code in javascript:
document.getElementById("controlName").style.visibility = "visible";
Regards,
Sandeep Kumar.V
|
|
|
|
|
i will attend an online exam of .net next week of a big company. It will be too difficult. How can pass and how can i prepare for that and can i get some sample questions.
Thanks
yesu
|
|
|
|
|
|
Can anyone give me a example? I want to remember Username and password, I don't know how to do?
Regard
Socheat
................
|
|
|
|
|
Hi,
Your question is not saying anything.
Not able to answer.
Try in google.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
I mean to i want to use cookie but I don't know
................
|
|
|
|
|
Where you want to remember your username and password ? In mind or somewhere else ?
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
I mean that i use cookie to remember, but i don't know
................
|
|
|
|
|
My friend Cookies are not safe to use. If your application is not very concern about security then you can use cookies
it is very simple
<br />
Cookie["UserName"] = UserNameTextBox.Text;<br />
Cookie["Password"] = PasswordTextBox.Text;<br />
string username= Cookie["UserName"];<br />
string password= Cookie["Password"];<br />
<br />
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
So do you have any comment for me?
Thanks and Regards
Socheat
................
|
|
|
|
|