Click here to Skip to main content
16,005,178 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
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 
Hi,
I have modified the code. You copy and paste this and check.
private void ibtnAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)<br />
		{<br />
			Classes.CChecklist cchecklist = new Classes.CChecklist();<br />
			dgChecklist.AutoGenerateColumns = true;<br />
			int cnt;<br />
			if(lbISOClauseNo.Items.Count > 0 && lbISODesc.Items.Count > 0 && txtExpected.Text != "" && txtTimeAllocated.Text != "")<br />
			{<br />
				for(cnt = 0 ; cnt < lbISOClauseNo.Items.Count ; cnt++)<br />
				{<br />
					if(cnt == lbISOClauseNo.Items.Count -1)<br />
					{<br />
						htxtFISOClauseNo.Value += lbISOClauseNo.Items[cnt].Value;<br />
						htxtFISOClauseDesc.Value += lbISODesc.Items[cnt].Value;<br />
					}<br />
					else<br />
					{<br />
						htxtFISOClauseNo.Value += lbISOClauseNo.Items[cnt].Value + "," ;<br />
						htxtFISOClauseDesc.Value += lbISODesc.Items[cnt].Value + "," ;<br />
					}<br />
				}<br />
				htxtFExpected.Value = txtExpected.Text;<br />
				htxtFTimePlanned.Value = txtTimeAllocated.Text;<br />
				cnt = Int32.Parse(htxtFChecklistNo.Value);<br />
				cnt++;<br />
				htxtFChecklistNo.Value = cnt.ToString();<br />
			}<br />
			if(ViewState["dtbl"]!=null)<br />
			{<br />
				//Datatable is available in viewstate.<br />
				DataRow dr = dt.NewRow();<br />
				dr["Checklist No"] = htxtFChecklistNo.Value;<br />
				dr["ISO Clause No"] = htxtFISOClauseNo.Value;<br />
				dr["Activities"] = htxtFISOClauseDesc.Value;<br />
				dr["Expected"] = htxtFExpected.Value;<br />
				dr["Time Allocated"] = htxtFTimePlanned.Value;<br />
<br />
				DataTable dt = (DataTable)ViewState["dtbl"];<br />
				dt.Rows.Add(dr);<br />
				ViewState["dtbl"] = dt;<br />
				dgChecklist.DataSource = (DataTable)ViewState["dtbl"];<br />
				dgChecklist.DataBind();<br />
			}<br />
			else<br />
			{<br />
				DataTable dt = new DataTable("CheckList");<br />
				//Checklist No<br />
				DataColumn dc = new DataColumn();<br />
				dc = dt.Columns.Add("Checklist No",System.Type.GetType("System.Int32"));<br />
				dc.Caption = "checklist_no";<br />
<br />
				//ISO Clause No<br />
				dc = dt.Columns.Add("ISO Clause No",System.Type.GetType("System.String"));<br />
				dc.Caption = "checklist_isoclause";<br />
<br />
				//Activities<br />
				dc = dt.Columns.Add("Activities",System.Type.GetType("System.String"));<br />
				dc.Caption = "checklist_activities";<br />
<br />
				//Expected Evidence<br />
				dc = dt.Columns.Add("Expected",System.Type.GetType("System.String"));<br />
				dc.Caption = "checklist_expected";<br />
<br />
				//Time Planned<br />
				dc = dt.Columns.Add("Time Allocated",System.Type.GetType("System.String"));<br />
				dc.Caption = "checklist_timeplanned";<br />
				ViewState["dtbl"] = dt;<br />
<br />
				DataRow dr = dt.NewRow();<br />
				dr["Checklist No"] = htxtFChecklistNo.Value;<br />
				dr["ISO Clause No"] = htxtFISOClauseNo.Value;<br />
				dr["Activities"] = htxtFISOClauseDesc.Value;<br />
				dr["Expected"] = htxtFExpected.Value;<br />
				dr["Time Allocated"] = htxtFTimePlanned.Value;<br />
<br />
				dt.Rows.Add(dr);<br />
<br />
				dgChecklist.DataSource = dt;<br />
				dgChecklist.DataBind();<br />
			}


And see where you were doing wrong. Big Grin | :-D : -D

Best Regards,
Apurva Kaushal
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 
Questionwhich is better ? Pin
anj198314-Jun-06 9:10
anj198314-Jun-06 9:10 
AnswerRe: which is better ? Pin
Elina Blank14-Jun-06 9:27
sitebuilderElina Blank14-Jun-06 9:27 
QuestionDatagrid; using multiple tables and getting blank row Pin
leckey14-Jun-06 8:45
leckey14-Jun-06 8:45 
AnswerRe: Datagrid; using multiple tables and getting blank row Pin
ToddHileHoffer14-Jun-06 9:07
ToddHileHoffer14-Jun-06 9:07 
GeneralRe: Datagrid; using multiple tables and getting blank row Pin
leckey14-Jun-06 9:12
leckey14-Jun-06 9:12 

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.