Click here to Skip to main content
16,004,974 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Custom Control post back raises Validation Control's Validate event Pin
minhpc_bk14-May-06 7:09
minhpc_bk14-May-06 7:09 
QuestionI want info about Editable Datagrid Pin
Yuwraj12-May-06 21:14
Yuwraj12-May-06 21:14 
AnswerRe: I want info about Editable Datagrid Pin
Sunrise Shine13-May-06 19:56
Sunrise Shine13-May-06 19:56 
QuestionMultiple datagrid Pin
kuwl_mark12-May-06 20:40
kuwl_mark12-May-06 20:40 
QuestionPage contents get jumbled in Firefox Pin
Dsypher12-May-06 20:20
Dsypher12-May-06 20:20 
AnswerRe: Page contents get jumbled in Firefox Pin
Michael Hendrickx13-May-06 22:01
Michael Hendrickx13-May-06 22:01 
QuestionCopying file from remote system to server. Pin
jaintirthesh12-May-06 20:05
jaintirthesh12-May-06 20:05 
QuestionHelp me in Datagrid with Static Datatable object Pin
cloudking1196612-May-06 19:29
cloudking1196612-May-06 19:29 
Hi My boss asked me to develop an application where it uses datagrid and left most corner I will have "+" and "-" image buttons. On click of "+", a blank record need to be added into datagrid, so that user can insert a new record. Onclick of "-", it should delete the particular record.

Well I implemented the same. But I used Static datatable to insert new record, so that the value will persist across post backs. Everything worked fine, as soon I started testing I found a big error.

While two persons starts working in same page from different PCs, other person's insertions are visible to the first person. I understood its because of static. The static datatable is being shared across the users!!.

But I gone so long that I can not think of going back now. I have done around 15 pages in the same way!!!, so going backward I can not even imagine.

Is there any alternative?, instead of using static datatable, can I use any other alternative?
below is my code snippet

//Declared as class variable
static DataTable dt;

//// When user clicks "+" or "-" button in datagrid

private void dgGoals_ItemCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//Each row in datagrid will have + and - imagebuttons at left most column

//Updates the datatable
updateDataTable();
//IF the user has clicked "+" image in datagrid right most column
if(e.CommandName.ToString()=="+")
{
// Adds a new row to datatable, so that after binding
// to datatagrid, it shows a blank row in datagrid
DataRow drow=dt.NewRow();
dt.Rows.Add(drow);
updateDataTable();
bindData();
}
//If the user clicks "-" image button in datagrid's left most column

else if(e.CommandName.ToString()=="-")
{
//The first column of Datagrid has serial number(1,2,3,4...)
//If the user clicks "-" it removes row at that position
dt.Rows.RemoveAt(Convert.ToInt32(e.Item.Cells[0].Text)-1);
}
bindData();
}
}
}



/* Update the datatable before moving to some other page in Datagrid etc*/
private void updateDataTable()
{
for(int k=0;k
AnswerRe: Help me in Datagrid with Static Datatable object Pin
minhpc_bk14-May-06 7:08
minhpc_bk14-May-06 7:08 
Questionconverting to text Pin
ptvce12-May-06 19:15
ptvce12-May-06 19:15 
AnswerRe: converting to text Pin
Colin Angus Mackay13-May-06 2:44
Colin Angus Mackay13-May-06 2:44 
Questionconverting Pin
ptvce12-May-06 19:15
ptvce12-May-06 19:15 
AnswerRe: converting Pin
Michael Hendrickx13-May-06 22:09
Michael Hendrickx13-May-06 22:09 
AnswerRe: converting Pin
_AK_14-May-06 19:55
_AK_14-May-06 19:55 
GeneralRe: converting Pin
ptvce14-May-06 21:00
ptvce14-May-06 21:00 
QuestionDynamic Datagrid Pin
kuwl_mark12-May-06 18:51
kuwl_mark12-May-06 18:51 
AnswerRe: Dynamic Datagrid Pin
cloudking1196612-May-06 19:40
cloudking1196612-May-06 19:40 
GeneralRe: Dynamic Datagrid Pin
kuwl_mark12-May-06 20:46
kuwl_mark12-May-06 20:46 
GeneralRe: Dynamic Datagrid Pin
kuwl_mark12-May-06 20:49
kuwl_mark12-May-06 20:49 
Questiona page is being Loaded towice without past back Pin
Masood Ahmed12-May-06 15:33
Masood Ahmed12-May-06 15:33 
AnswerRe: a page is being Loaded towice without past back Pin
minhpc_bk14-May-06 7:06
minhpc_bk14-May-06 7:06 
QuestionTree View Control Pin
JoJuPi0112-May-06 14:11
JoJuPi0112-May-06 14:11 
AnswerRe: Tree View Control Pin
minhpc_bk14-May-06 7:04
minhpc_bk14-May-06 7:04 
QuestionConnecting to SQL Pin
Taterface12-May-06 7:35
Taterface12-May-06 7:35 
AnswerRe: Connecting to SQL Pin
MoustafaS12-May-06 11:41
MoustafaS12-May-06 11:41 

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.