Click here to Skip to main content
15,898,791 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: HTML Input Box Dynamically set default value Pin
dptalt27-Aug-09 4:44
dptalt27-Aug-09 4:44 
GeneralRe: HTML Input Box Dynamically set default value Pin
Coding C#27-Aug-09 21:07
Coding C#27-Aug-09 21:07 
AnswerRe: HTML Input Box Dynamically set default value Pin
Robert_Pan27-Aug-09 14:32
Robert_Pan27-Aug-09 14:32 
GeneralRe: HTML Input Box Dynamically set default value Pin
Robert_Pan27-Aug-09 14:33
Robert_Pan27-Aug-09 14:33 
QuestionCustom Paging Pin
.NET- India 27-Aug-09 3:10
.NET- India 27-Aug-09 3:10 
AnswerRe: Custom Paging Pin
Coding C#27-Aug-09 4:01
Coding C#27-Aug-09 4:01 
GeneralRe: Custom Paging Pin
Coding C#27-Aug-09 4:13
Coding C#27-Aug-09 4:13 
GeneralRe: Custom Paging Pin
.NET- India 27-Aug-09 23:22
.NET- India 27-Aug-09 23:22 
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 = "&nbsp;";
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";
}
QuestionUsing profile as custom class (getting null while taking data from profile _ Pin
justintimberlake27-Aug-09 1:21
justintimberlake27-Aug-09 1:21 
AnswerRe: Using profile as custom class (getting null while taking data from profile _ Pin
Ibrahim Bello27-Aug-09 1:37
Ibrahim Bello27-Aug-09 1:37 
GeneralRe: Using profile as custom class (getting null while taking data from profile _ Pin
justintimberlake27-Aug-09 1:57
justintimberlake27-Aug-09 1:57 
GeneralRe: Using profile as custom class (getting null while taking data from profile _ Pin
Ibrahim Bello27-Aug-09 2:23
Ibrahim Bello27-Aug-09 2:23 
QuestionUrl rewrite Pin
Ramkumar_S27-Aug-09 1:21
Ramkumar_S27-Aug-09 1:21 
AnswerRe: Url rewrite Pin
SeMartens27-Aug-09 2:39
SeMartens27-Aug-09 2:39 
GeneralRe: Url rewrite Pin
Ramkumar_S27-Aug-09 3:04
Ramkumar_S27-Aug-09 3:04 
GeneralRe: Url rewrite Pin
SeMartens27-Aug-09 3:13
SeMartens27-Aug-09 3:13 
QuestionDatalist itemtemplate : hide text box through javascript Pin
Hemant Thaker27-Aug-09 0:45
Hemant Thaker27-Aug-09 0:45 
AnswerRe: Datalist itemtemplate : hide text box through javascript Pin
Arun Jacob27-Aug-09 1:03
Arun Jacob27-Aug-09 1:03 
GeneralRe: Datalist itemtemplate : hide text box through javascript Pin
Expert-Net-Developer27-Aug-09 2:16
Expert-Net-Developer27-Aug-09 2:16 
GeneralRe: Datalist itemtemplate : hide text box through javascript Pin
Hemant Thaker27-Aug-09 2:22
Hemant Thaker27-Aug-09 2:22 
Questionpopulate form Pin
mylogics27-Aug-09 0:21
professionalmylogics27-Aug-09 0:21 
AnswerRe: populate form Pin
Coding C#27-Aug-09 0:47
Coding C#27-Aug-09 0:47 
GeneralRe: populate form Pin
mylogics27-Aug-09 0:55
professionalmylogics27-Aug-09 0:55 
GeneralRe: populate form Pin
nagendrathecoder27-Aug-09 1:12
nagendrathecoder27-Aug-09 1:12 
QuestionGauge Control (Speedometer) chart in asp.net [modified] Pin
rahul.net1127-Aug-09 0:07
rahul.net1127-Aug-09 0:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.