|
Hi,
I am using static variables for storing some data like pageindex, some table data and like that.
It works fine. No problems. But the scope of static variable is for whole application. I mean if there are 10 user connected to my application then they all share the same value of static variables. So it may creates some problems and it is obvious. So what should I do now. Because application is now completely developed. So should I use ViewState in place of all Static variables or what?
So please give me way for this.
Thanks in advance.
Naresh Patel
|
|
|
|
|
It depends what scope you want for you variables. If you want it to be for that user only then you can use session or if you just want to have that for the life of that page then you can use viewstate.
Apurva Kaushal
|
|
|
|
|
Yaa But the number of session variables increase it may deduce the performance as I think. And the viewstate store all data into the page so it may also affect performance.
Naresh Patel
|
|
|
|
|
N a r e s h P a t e l wrote: Yaa But the number of session variables increase it may deduce the performance
Well the data has to be stored SOMEWHERE! I'd go with Session.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
But if you are just storing some small value in session it won't affect the performance that much. And also as Colin told you have to store it somewhere so you can choose you way.
Apurva Kaushal
|
|
|
|
|
i have one button and one gridview in that i have filled data using
public void GetData()
{ SqlConnection con = new SqlConnection(constr);
string cmd = "select a.errname as ErrorName, m.errortype as ErrorType,
a.errpointsdeducted as PointsDeduction, convert(varchar,a.createddate,104)
as CreatedDate from auditerrors a,auditerrormaster m where
a.errtypeid=m.internalid order by m.errortype";
SqlDataAdapter da = new SqlDataAdapter(cmd,con);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
da.Fill(ds, "auditerrors");
dt = ds.Tables["auditerrors"];
gvAuditErrors.DataSource=ds.Tables[0];
gvAuditErrors.DataBind();}
in the same project i have another page with one text box in it. i want user to select a row in the gridview and click on the button to modify the createddate of that particular row (for this i have provided textbox in the other page, i want that selected row's date to be in the textbox control)
if anybody got the solution plz do let me know
tasks:
selecting a row on double clicking the row
transfering the content from first page to the other
2 hrs back i have posted the same question to C# forum but i did'nt got any sol. till now anyway my project is related to both the forums
regards
sunil
|
|
|
|
|
Call Javascript:Window.Open() method on the click of the record by passing the ID of the Selected Row as QueryString and then Query the Database for the neccessary details of the particular Record and show it on the popup page.
window.Open("SecondPage.aspx?Id="+val)
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
John Prabhu wrote: on the click of the record by passing the ID of the Selected Row as QueryString
the main problem for me is passing ID of the selected row
sir can you please tell me in detail how to pass the ID of the selected row if possible with example
regards
sunil
|
|
|
|
|
I have a scnario in my page. when user entered two dates(From and Todate) in textboxes and click on a button the gridview should display boundcolumns and template columns(vary depends on dates range). Ex, user give 19/11/2007 and 21/11/2007. and clicked on button the Gridview will be
____________________________________________________________
ID(col1) Name(col2) 19/11/2007(col3) 20/11/2007(col4) 21/11/2007 (col5)
------------------------------------------------------------
12 aaaaa image1 Image2 Image2
13 bbbbb image2 image3 Image4
......................................
.......................................
ID and Name are boundfield columns but 19/11/2007 20/11/2007 21/11/2007(Headers) are template columns......template column contains imagebutton control....
if user give the dates 19/11/2007 and 20/11/2007 and clicked on button, the gridview will be
___________________________________________
ID.... Name... 19/11/2007... 20/11/2007 (Headers)
--------------------------------------------
12.... aaaaa .... image1 ........ Image2
13.... bbbbb .... image2 ......... image3
......................................
.......................................
Can anyone give me solution ?am using asp.net 2.0 and c#
Thanks in advance.
|
|
|
|
|
Check this article:
http://www.gridviewguy.com/ArticleDetails.aspx?articleID=88
|
|
|
|
|
hi any body please help me iam converting vb.net code to c# while doing this i got problem near convertion datediff(dateinterval.day,submitted,completed)
with ths above code in vb iam getting output in days i.e 23 but in c# iam getting thre output as 23.14:33:01 can anybody resolves it
here i used the datetime completed=datetime.today and submitted=datetime.minvalue
|
|
|
|
|
How u r getting this "23.14:33:01" value, I mean in which variable u are saving it, can u please post the hole code???
|
|
|
|
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class ExtEltSetTimeStamp : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
label3.Text = " Showing COMPLETED Elements ";
if (Session != null)
{
}
else
{
Response.Redirect("Login.aspx");
}
if (!Page.IsPostBack)
{
GridView1.PageIndex = 0;
GridView2.PageIndex = 0;
fillgridview();
label2.Text = "1 out of" + GridView1.PageCount;
label2.Text = "1 out of" + GridView2.PageCount;
GridView2.Visible = false;
}
}
public void fillgridview()
{
DataSet ds;
// DataRow[] dr;
try
{
int y = 0;
bool iscompleted = false;
DateTime submitted = DateTime.Today;
DateTime completed = DateTime.MinValue;
TimeSpan ts;
//DataTable tbliscompleted = new DataTable();
//DataTable tblinprogress = new DataTable();
//string columnname="";
//ds = clsSqlDataProvider.ExtElement_GetRequisitionTime(Convert.ToInt32(Session["LoginId"].ToString()), "1");
clsSqlDataProvider dp = new clsSqlDataProvider();
ds = dp.ExtElement_GetRequisitionTime(112, "1");
DataTable dtCompleted = new DataTable();
dtCompleted.Columns.Add("Description", System.Type.GetType("System.String"));
dtCompleted.Columns.Add("Scope", System.Type.GetType("System.String"));
dtCompleted.Columns.Add("GICSCodeDesc", System.Type.GetType("System.String"));
dtCompleted.Columns.Add("SubmittedDate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("DcDate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("EADate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("HUDate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("PSDate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("DUDate", System.Type.GetType("System.DateTime"));
dtCompleted.Columns.Add("TotalTimeTakentoComplete(Days)", System.Type.GetType("System.TimeSpan"));
//dtCompleted.Columns.Add("TotalTimeTakentoComplete(Days)", System.Type.GetType("System.Int32"));
DataTable dtInProgress = new DataTable();
dtInProgress = dtCompleted;
DataRow[] drows;
string nReqID = "";
while (y < ds.Tables[0].Rows.Count)
{
DataRow drDT;
drDT = dtCompleted.NewRow();
nReqID = ds.Tables[0].Rows[y][0].ToString();
drDT[0] = ds.Tables[0].Rows[y][1].ToString();
drDT[1] = ds.Tables[0].Rows[y][5].ToString();
drDT[2] = ds.Tables[0].Rows[y][7].ToString();
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=2 and NewAddStatus=3");
if (drows != null && drows.Length > 0)
{
//foreach (DataRow drow in drows)
//{
// submitted = drow[3];
//}
submitted = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
iscompleted = false;
drDT[3] = submitted.ToString();
}
else
{
drDT[3] = DBNull.Value;
}
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=2 and NewAddStatus=2");
if (drows != null && drows.Length > 0)
{
completed = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
drDT[4] = completed.ToString();
//string [7] StrDay = completed.split(new char {'.'})
}
else
{
drDT[4] = DBNull.Value;
}
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=3 and NewAddStatus=2");
if (drows != null && drows.Length > 0)
{
completed = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
drDT[5] = completed.ToString();
}
else
{
drDT[5] = DBNull.Value;
}
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=4 and NewAddStatus=2");
if (drows != null && drows.Length > 0)
{
completed = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
drDT[6] = completed.ToString();
}
else
{
drDT[6] = DBNull.Value;
}
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=5 and NewAddStatus=2");
if (drows != null && drows.Length > 0)
{
completed = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
drDT[7] = completed.ToString();
}
else
{
drDT[7] = DBNull.Value;
}
drows = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=6 and NewAddStatus=2");
if (drows != null && drows.Length > 0)
{
completed = Convert.ToDateTime(drows[drows.Length - 1][3].ToString());
iscompleted = true;
drDT[8] = completed.ToString();
}
else
{
drDT[8] = DBNull.Value;
}
if (iscompleted == true)
{
//completed.Subtract(14);
ts = completed - submitted;
//ts = completed.Subtract(submitted);
//DateTime tsh=Convert.ToDateTime - submitted.Hour;
//ts = tsh;
//DateTime tsm = completed.Minute - submitted.Minute;
//DateTime tss = completed.Minute - submitted.Minute;
//int intDays = ts.Days;
//drDT[9] = intDays;
drDT[9] = ts;
dtCompleted.Rows.Add(drDT);
}
else
{
if (completed == DateTime.MinValue)
{
drDT[9] = "0";
}
else
{
ts = completed - submitted;
// ts = completed.Subtract(submitted);
//int intDays = ts.Days;
if (ts.Ticks > 0)
{
drDT[9] = ts.ToString();
}
else
{
drDT[9] = 0.ToString();
}
}
dtInProgress.Rows.Add(drDT);
}
y += 1;
}
GridView1.DataSource = dtCompleted;
GridView1.DataBind();
GridView2.DataSource = dtInProgress;
GridView2.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
fillgridview();
label2.Text = e.NewPageIndex + 1 + " out of " + GridView1.PageCount;
}
public void fillgrid()
{
DataSet ds;
try
{
int y = 0;
bool isprogress = false;
DateTime submitted = DateTime.Today;
DateTime progress = DateTime.MinValue;
TimeSpan ts1;
//ds = clsSqlDataProvider.ExtElement_GetRequisitionTime(Convert.ToInt32(Session["LoginId"].ToString()), "1");
clsSqlDataProvider dp = new clsSqlDataProvider();
ds = dp.ExtElement_GetRequisitionTime(112, "1");
DataTable tblinprogress = new DataTable();
tblinprogress.Columns.Add("Description", System.Type.GetType("System.String"));
tblinprogress.Columns.Add("Scope", System.Type.GetType("System.String"));
tblinprogress.Columns.Add("GICSCodeDesc", System.Type.GetType("System.String"));
tblinprogress.Columns.Add("SubmittedDate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("DcDate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("EADate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("HUDate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("PSDate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("DUDate", System.Type.GetType("System.DateTime"));
tblinprogress.Columns.Add("TotalTimeTakentoComplete(Days)", System.Type.GetType("System.TimeSpan"));
DataRow[] drows1;
string nReqID = "";
while (y < ds.Tables[0].Rows.Count)
{
DataRow drDT1;
drDT1 = tblinprogress.NewRow();
nReqID = ds.Tables[0].Rows[y][0].ToString();
drDT1[0] = ds.Tables[0].Rows[y][1].ToString();
drDT1[1] = ds.Tables[0].Rows[y][5].ToString();
drDT1[2] = ds.Tables[0].Rows[y][7].ToString();
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=2 and NewAddStatus=3");
if (drows1 != null && drows1.Length > 0)
{
//foreach (DataRow drow in drows)
//{
// submitted = drow[3];
//}
submitted = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
isprogress = false;
drDT1[3] = submitted.ToString();
}
else
{
drDT1[3] = DBNull.Value;
}
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=2 and NewAddStatus=2");
if (drows1 != null && drows1.Length > 0)
{
progress = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
drDT1[4] = progress.ToString();
}
else
{
drDT1[4] = DBNull.Value;
}
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=3 and NewAddStatus=2");
if (drows1 != null && drows1.Length > 0)
{
progress = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
drDT1[5] = progress.ToString();
}
else
{
drDT1[5] = DBNull.Value;
}
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=4 and NewAddStatus=2");
if (drows1 != null && drows1.Length > 0)
{
progress = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
drDT1[6] = progress.ToString();
}
else
{
drDT1[6] = DBNull.Value;
}
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=5 and NewAddStatus=2");
if (drows1 != null && drows1.Length > 0)
{
progress = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
drDT1[7] = progress.ToString();
}
else
{
drDT1[7] = DBNull.Value;
}
drows1 = ds.Tables[1].Select("Reqid=" + nReqID + "And NewStatus=6 and NewAddStatus=2");
if (drows1 != null && drows1.Length > 0)
{
progress = Convert.ToDateTime(drows1[drows1.Length - 1][3].ToString());
isprogress = true;
drDT1[8] = progress.ToString();
}
else
{
drDT1[8] = DBNull.Value;
}
if (isprogress == true)
{
ts1 = submitted - progress;
drDT1[9] = ts1;
}
else
{
if (progress == DateTime.MinValue)
{
drDT1[9] = "0";
}
else
{
ts1 = submitted - progress;
if (ts1.Ticks > 0)
{
drDT1[9] = ts1.ToString();
}
else
{
drDT1[9] = 0.ToString();
}
}
}
tblinprogress.Rows.Add(drDT1);
y += 1;
}
GridView2.DataSource = tblinprogress;
GridView2.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
GridView1.Visible = false;
GridView2.Visible = true;
Label1.Text = "Showing IN PROGRESS Elements";
label3.Visible = false;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
GridView2.Visible = false;
Label1.Text = "Showing COMPLETED Elements";
label3.Visible = false;
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView2.PageIndex = e.NewPageIndex;
fillgridview();
label2.Text = e.NewPageIndex + 1 + "out of " + GridView2.PageCount;
}
}
|
|
|
|
|
i have set the data from database through form view..all the rows came with insert item template..but while running the page the form view is not coming.i want to add the item in running time.in sqldatasource properties there is also isert quiry..while click on quirybuilder,it showing insert quiry error cant pass string.wht z the solution
|
|
|
|
|
Hello Everybody,
I want to design a gridview where there is a option to create a new row for the user. suppose there is a button and by clicking the button a new blank row added to the gridview. The user can add more than one row. If possible make the button present in a column of the gridview so that when the user click the button a new row created along with the button column also.
plz give some idea to do or the solution.
Happy Coding...
AS@13
AS
|
|
|
|
|
You can take a look at this[^]. This will help you out in that.
Apurva Kaushal
|
|
|
|
|
Hi,
Thanks yaar..
But it not solve my problem...
the problem is that the button should be in last column of the Gridview and user can create more than one row as per the requirement..
plz help me out..
Happy Coding
AS
|
|
|
|
|
Regarding the columns you can have it where ever you want. And for adding multiple rows once he has added one record afterwards he can again add another one.
Apurva Kaushal
|
|
|
|
|
But I also want to display those new entries in gridview to the user. plz send me the code if u have.
Thanks
AS
|
|
|
|
|
Once he has added the row you can bind the gridview again after that you will get the gridview with the added row.
Apurva Kaushal
|
|
|
|
|
|
Always welcome..
Apurva Kaushal
|
|
|
|
|
Hi, i need to do paging in datalist / datagrid, like the scenario i write below. All the values are fetching from database. in this case the paging options are A-C, D-G, ... I hope you people can understand. I need its solution little urgent.
Please give me any suggestion.
------------------------------------------------------------------------------------------------------
A - C D - G H - K L - N O - R S - V W - Z
A
ABB | Acme | AC Tech Drives | Adalet | Advance | AEG | Allied Molded Products | Amprobe | Asco
B
Bernstein | B-Line | Bodine
C
Cablofil | Carlo Gavazzi | Carlon | Coleman | Cooper | Crouse-Hinds | Cooper Power | Cooper Wiring | Cully
Regards, Sohail Arshed
|
|
|
|
|
Have a custom Paging build in the Footer Template of the DataList Control using Link Buttons with the Command argument as "A,B,C" for the first link button and "D,E,F,G" for the second and so on... On the ItemCommand Event of the DataList Control call the DB procedure by passing the Command argument and get the appropriate records and Bind them.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Dropdown list has two properties called TextField and ValueField
When ur TextField is 2008-2009 assign value field to 2007-2008 and same for all other rows..
|
|
|
|