Click here to Skip to main content
15,922,015 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Bind Datagrid With Viewstate Pin
Tirthadip14-Jun-06 19:55
Tirthadip14-Jun-06 19:55 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 20:24
varshavmane14-Jun-06 20:24 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 20:29
_AK_14-Jun-06 20:29 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 20:36
varshavmane14-Jun-06 20:36 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 20:41
_AK_14-Jun-06 20:41 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 20:45
varshavmane14-Jun-06 20:45 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 20:49
_AK_14-Jun-06 20:49 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 21:00
varshavmane14-Jun-06 21:00 
Fllowing is the code what I have used:


private void ibtnAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Classes.CChecklist cchecklist = new Classes.CChecklist();
dgChecklist.AutoGenerateColumns = true;
DataTable dt = new DataTable("CheckList");
int cnt;
if(lbISOClauseNo.Items.Count > 0 && lbISODesc.Items.Count > 0 && txtExpected.Text != "" && txtTimeAllocated.Text != "")
{
for(cnt = 0 ; cnt < lbISOClauseNo.Items.Count ; cnt++)
{
if(cnt == lbISOClauseNo.Items.Count -1)
{
htxtFISOClauseNo.Value += lbISOClauseNo.Items[cnt].Value;
htxtFISOClauseDesc.Value += lbISODesc.Items[cnt].Value;
}
else
{
htxtFISOClauseNo.Value += lbISOClauseNo.Items[cnt].Value + "," ;
htxtFISOClauseDesc.Value += lbISODesc.Items[cnt].Value + "," ;
}
}
htxtFExpected.Value = txtExpected.Text;
htxtFTimePlanned.Value = txtTimeAllocated.Text;
cnt = Int32.Parse(htxtFChecklistNo.Value);
cnt++;
htxtFChecklistNo.Value = cnt.ToString();
}
//Checklist No
DataColumn dc = new DataColumn();
dc = dt.Columns.Add("Checklist No",System.Type.GetType("System.Int32"));
dc.Caption = "checklist_no";

//ISO Clause No
dc = dt.Columns.Add("ISO Clause No",System.Type.GetType("System.String"));
dc.Caption = "checklist_isoclause";

//Activities
dc = dt.Columns.Add("Activities",System.Type.GetType("System.String"));
dc.Caption = "checklist_activities";

//Expected Evidence
dc = dt.Columns.Add("Expected",System.Type.GetType("System.String"));
dc.Caption = "checklist_expected";

//Time Planned
dc = dt.Columns.Add("Time Allocated",System.Type.GetType("System.String"));
dc.Caption = "checklist_timeplanned";

DataRow dr = dt.NewRow();

dr["Checklist No"] = htxtFChecklistNo.Value;
dr["ISO Clause No"] = htxtFISOClauseNo.Value;
dr["Activities"] = htxtFISOClauseDesc.Value;
dr["Expected"] = htxtFExpected.Value;
dr["Time Allocated"] = htxtFTimePlanned.Value;

dt.Rows.Add(dr);

//Bind Datatable with DataGrid
dgChecklist.DataSource = dt;
dgChecklist.DataBind();

//Clear all the textbox and listbox.
lbISOClauseNo.Items.Clear();
lbISODesc.Items.Clear();
txtExpected.Text = "";
txtTimeAllocated.Text = "";

htxtFExpected.Value = "";
htxtFISOClauseDesc.Value = "";
htxtFISOClauseNo.Value = "";
htxtFTimePlanned.Value = "";
}


Whenever I click on add button datatable gets created again and I lose my last record.So I am in problem.

Please tell me how do I handle this
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 21:22
_AK_14-Jun-06 21:22 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 22:17
varshavmane14-Jun-06 22:17 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 22:37
_AK_14-Jun-06 22:37 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 22:46
varshavmane14-Jun-06 22:46 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 22:58
_AK_14-Jun-06 22:58 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 23:09
varshavmane14-Jun-06 23:09 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_14-Jun-06 23:10
_AK_14-Jun-06 23:10 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane14-Jun-06 23:21
varshavmane14-Jun-06 23:21 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_15-Jun-06 0:37
_AK_15-Jun-06 0:37 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane15-Jun-06 0:48
varshavmane15-Jun-06 0:48 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_15-Jun-06 1:13
_AK_15-Jun-06 1:13 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane15-Jun-06 1:25
varshavmane15-Jun-06 1:25 
GeneralRe: Bind Datagrid With Viewstate Pin
_AK_15-Jun-06 1:33
_AK_15-Jun-06 1:33 
GeneralRe: Bind Datagrid With Viewstate Pin
varshavmane15-Jun-06 1:46
varshavmane15-Jun-06 1:46 
Questionasp.net application with recordset Pin
Sameer Salkar14-Jun-06 17:54
Sameer Salkar14-Jun-06 17:54 
QuestionHyperlinkcolumn - change color of link Pin
NewbieDave14-Jun-06 12:04
NewbieDave14-Jun-06 12:04 
AnswerRe: Hyperlinkcolumn - change color of link Pin
minhpc_bk14-Jun-06 16:18
minhpc_bk14-Jun-06 16:18 

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.