|
Hi,
Would you mind pasting you code here?
That will help people where the issue is, this is some logical mistake I guess so.
|
|
|
|
|
When you click on Next button the "page no, Next" text is set in the link title, is that anything to do with the logic?
When you click on page no link, same text is replace by "Page no, Paging No.".
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
//Keep at top because it specifies the total no. of records available in the table
if (!Page.IsPostBack)
{
//Current Page No.
ViewState["Current_PNo"] = 1;
//State Page No.
ViewState["Current_Start"] = 1;
//Last Page No.
ViewState["Current_Last"] = 4;
//lblMsg.Text = ViewState["Current_Start"].ToString() + "," + ViewState["Current_Last"].ToString();
//Set MaxRow
ViewState["MaxRow"] = 10;
//startNo and maxNo
bindDataList(1, int.Parse(ViewState["MaxRow"].ToString()));
//Creates the paging nos i.e. 1,2,3,4
createPagingControl(int.Parse(ViewState["Current_Start"].ToString()),int.Parse(ViewState["Current_Last"].ToString()));
}
else
{
int start = Convert.ToInt32(ViewState["Current_Start"].ToString());
int last= Convert.ToInt32(ViewState["Current_Last"].ToString());
createPagingControl(start,last);
}
}
public void bindDataList(int startRow,int maxRow)
{
using (SqlConnection mCon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
{
int maxRow_New = startRow + maxRow;
Session["MaxRow"] = maxRow_New.ToString();
//string strsql = "Select * From Table2 Where Active=1 and ID>="+startRow+" and ID<="+maxRow_New+" ";
string strsql = null;
strsql="Select *,Total=(Select Count(*) From Table2 Where Active=1) "+
"From Table2 Where Active=1 and ID>="+startRow+" and ID<="+maxRow+" ";
SqlCommand mDataCom = new SqlCommand();
mDataCom.Connection = mCon;
mDataCom.CommandText = strsql;
mDataCom.CommandType = CommandType.Text;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(mDataCom);
da.Fill(ds);
PagedDataSource page = new PagedDataSource();
page.AllowPaging = true;
//Set Total No. of Rows in the Database
ViewState["RowCount"] = ds.Tables[0].Rows[0]["Total"].ToString();
//Set maxRow
page.PageSize = int.Parse(ViewState["MaxRow"].ToString());
page.DataSource = ds.Tables[0].DefaultView;
//DataList1.DataSource = ds.Tables[0];
DataList1.DataSource = page;
DataList1.DataBind();
}
}
public void createPagingControl(int start,int last)
{
int rowCount = Convert.ToInt32(ViewState["RowCount"].ToString());
PlaceHolder1.Controls.Clear();
if (rowCount / int.Parse(ViewState["MaxRow"].ToString()) >= last)
{
for (int i = start; i <= last; i++)
{
LinkButton lnk = new LinkButton();
lnk.Text = i.ToString();
lnk.ToolTip = i.ToString() + ", Paging No.";
lnk.Click += new EventHandler(lnk_Click);
Label lbl = new Label();
lbl.Text = " ";
PlaceHolder1.Controls.Add(lnk);
PlaceHolder1.Controls.Add(lbl);
lnk.Style["text-decoration"] = "underline";
lnk.Style["Color"] = "DarkBlue";
lnk.Enabled = true;
}
}
}
public void lnk_Click(object sender, EventArgs e)
{
LinkButton lnk= sender as LinkButton;
lnk.Style["text-decoration"] = "none";
lnk.Style["Color"] = "Maroon";
lnk.Enabled = false;
int currentPage = int.Parse(lnk.Text);
//Multiply by maxRow
int maxRow = currentPage * int.Parse(ViewState["MaxRow"].ToString());
int startRow = currentPage == 1 ? 1 : maxRow - (int.Parse(ViewState["MaxRow"].ToString())-1);
bindDataList(startRow, maxRow);
}
public void lnkClick(int cureentPage)
{
//LinkButton lnk = sender as LinkButton;
LinkButton lnk = new LinkButton();
lnk.Text = cureentPage.ToString();
lnk.Style["text-decoration"] = "none";
lnk.Style["Color"] = "Maroon";
lnk.Enabled = false;
int currentPage = int.Parse(lnk.Text);
//Multiply by maxRow
int maxRow = currentPage * int.Parse(ViewState["MaxRow"].ToString());
int startRow = currentPage == 1 ? 1 : maxRow - (int.Parse(ViewState["MaxRow"].ToString()) - 1);
bindDataList(startRow, maxRow);
}
protected void lnkNext_Click(object sender, EventArgs e)
{
int start= Convert.ToInt32(ViewState["Current_Last"].ToString())+1;
int last = Convert.ToInt32(ViewState["Current_Last"].ToString()) + 4;
ViewState["Current_Start"] = start.ToString();
ViewState["Current_Last"] = last.ToString();
lblMsg.Text = ViewState["Current_Start"].ToString() + "," + ViewState["Current_Last"].ToString();
int currentPage = int.Parse(ViewState["Current_Start"].ToString());
ViewState["Empty"] = start.ToString();
lnkClick(currentPage);
createPagingControl(start,last);
//lblMsg.Text = "Next Clicked";
}
|
|
|
|
|
How can i use custom class a profile i have class
namespace MyCompany.CodeBlog{
[Serializable]
public class UserProfile
{
private string userid;
private string ipAddres;
private string name;
public static UserProfile GetUserProfile(string username)
{
return Create(username) as UserProfile;
}
public static UserProfile GetUserProfile()
{
return Create(Membership.GetUser().UserName) as UserProfile;
}
[SettingsAllowAnonymous(false)]
public string UserId
{
get
{
return userid;
}
set
{
userid = value;
}
}
[SettingsAllowAnonymous(false)]
public string IpAddress
{
get
{
return ipAddres;
}
set
{
ipAddres = value;
}
}
[SettingsAllowAnonymous(false)]
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
}
And i want to use this a profile in my web config file i have
< profile enabled="true">
< properties>
< add
name="UserProfile"
type="MyCompany.CodeBlog.UserProfile" />
< / properties >
< / profile >
in my login page after validating the user i used
Profile.UserProfile.UserId = "1";
Profile.UserProfile.Name = "myname";
Profile.UserProfile.IpAddress = "myip";
but in another page
if (Request.IsAuthenticated)
{
//Error here
string mystr = Profile.UserProfile.Name;
//mystr is null
}
So please guide me if i am completely wrong or i have missed some thing i dont want tto use propfile property in webconfg file
|
|
|
|
|
Try calling: Profile.Save(); after setting values for your profile...
|
|
|
|
|
Thank for your answer
But i have one question what does profile.save do does it save the data in the database or where does it save
|
|
|
|
|
It updates the current profile with the values provided. It saves to the SQLEXPRESS database(ASPNETDB)in your local App_Data folder (by default).
|
|
|
|
|
Hi
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,Intelligencia.UrlRewriter"/>
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter"/>
</httpModules>
<compilation debug="true"/></system.web>
<rewriter>
<rewrite url="~/products/books.aspx" to="~/products.aspx?category=books"/>
<rewrite url="~/products/CDs.aspx" to="~/products.aspx?category=CDs"/>
<rewrite url="~/products/DVDs.aspx" to="~/products.aspx?category=DVDs"/>
</rewriter>
</configuration>
I have included the bin file.
In the root i have ~/products/books.aspx,~/products/CDs.aspx ..files
when i try to give http://localhost:1890/products.aspx?category=CDs in browser ..i am getting this error
HTTP Error 404 - Not Found.
Plz help..
Or suggest me good and easy rewriting method
Ramkumar
|
|
|
|
|
Hi,
do you have a products.aspx in your root-folder?
|
|
|
|
|
Thanks for your time...
When i create products.aspx in your root-folder... it redirect to product.aspx page.. I want to redirect to Books.aspx page when i give
http://localhost:1890/Urlredirect1/products.aspx?category=books
Plz guid me where I am going wrong
Thanks in advance
Ramkumar
|
|
|
|
|
Well, than I guess you have to change your rewriting-configuration. If the client enters product.aspx you want to redirect to books.aspx. So it must be
<rewrite url="~/products.aspx?category=books" to="~/products/books.aspx" />
Regards
Sebastian
|
|
|
|
|
Hi....
I m using asp.net 2.0
I have datalist control and one button and a text box inside itemtemplate.
I want to hide textbox once the user clicks button in itemtemplate...but through javascript...
can u help me out...
thanks...
By:
Hemant Thaker
|
|
|
|
|
In ItemDataBound of datalist find the button and add attribute for the button like,
btnName.Attributes.Add("onclick","return EnableControl('" + txtName.ClientID + "');");
then write javascript method EnableControl and do as per your requirement.
|
|
|
|
|
funcation HideTextbox(obj)
{
obj.visibility:hidden;
}
in the itemdatabound event
button b1=(button) e.findcontrol(<buttonid>);
b1.Attributes.Add("onclick","return HideTextbox(this);");
|
|
|
|
|
Hi... thanks...
I m leaving for home , I may get this dont tonight...
It seems like u r from Gujarat...
As I know one of my friends..."Dabhi"...
Anyway...object button b1 is not created any how....means its not able to find respective control
see u
By:
Hemant Thaker
|
|
|
|
|
public void populatepage()
{
string s = Page.User.Identity.Name;
string str = "Select * From Company Where(Owner='s')";
SqlCommand cmd = new SqlCommand(str, conn);
SqlDataReader dr = null;
conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
txtcompname.Text = dr["CompanyName"].ToString();
txtcompaddress.Text = dr["CompanyAddress"].ToString();
txtmail.Text = dr["Email"].ToString();
txtphoneno.Text = dr["PhoneNo"].ToString();
txtpincode.Text = dr["PinCode"].ToString();
Button1.Visible = false;
Label1.Visible = true;
Label1.Text = "You have already created your company";
txtcompaddress.ReadOnly = true;
txtcompid.ReadOnly = true;
txtcompname.ReadOnly = true;
txtmail.ReadOnly = true;
txtphoneno.ReadOnly = true;
txtpincode.ReadOnly = true;
}
conn.Close();
}
i have written this code to poulate a form but it doesnt works.
all textbox are still empty.there is one row in database but it does not go in while loop....plz guide..
|
|
|
|
|
mylogics wrote: string str = "Select * From Company Where(Owner='s')";
Change it to
string str = "Select * From Company Where Owner='" + s + "'";
HTH
|
|
|
|
|
thnks...it worked
that means that string shud alwas b takn in double quotes n numeric values in single quotes.m i right...
|
|
|
|
|
Just watch the value of "str" in both scenarios (your's & above person's)while debugging the appl'n.
U'll come to know where u make mistake.
|
|
|
|
|
|
Hi
Did you get any clue on how to get this type of chart for asp.net? I am in need of a similar solution but could not get anything out from Google so far. Please share if you have got any (senthiljapss1 at gmail com)
|
|
|
|
|
i have a dropdownlist which has a name of students and two textboxs which has upper and lower limit of date of births.
i want to make a datasource for a gridview which
is
select * from Student where name=@name OR birthday BETWEEN (@lower) AND (@upper)
it doesnot work help
|
|
|
|
|
Why do you say it does not Work. Do you get some sort of Error
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
hey guys
i have a site thats show pictures.
i would like to focus on the picture with points that i will post...
is it possible ?
i tried to find some info about it and i couldnt find something...
can someone help me out ?
|
|
|
|
|