I have 2 tyext boxes:
 
1)varchar Text box
2)numeric Textbox
 
'SUBMIT' Buttton.
There is a DataGrid below this submit button.
 
I had dynamically created this datagrid and Added data.
 
While I am editing the values,Sometimes user may add some more items into the 
datagrid.For me it show only new datagrid value.
 
I need to append the values below the edited datagrid values.

private void Btn_addlist_Click(object sender, System.EventArgs e)

{

DataSet dstReqObj=new DataSet();

if(ItemsGrid.Items.Count>0)

{

display();



}

else

{

display();



}

}

private void display()

{

DataView dvView=new DataView();

dvView= CreateDataSource(); 



ItemsGrid.DataSource =dvView;

// Response.Write(i);

ItemsGrid.DataBind();

Session["ItemData"]= dvView;

}

public DataView CreateDataSource() 

{

DataTable dt = new DataTable("answerblock");

DataRow dr; 

DataColumn colResult;

DataColumn[] keys = new DataColumn[1];



 

 

DataView dvView=new DataView();

if(Session["ItemData"]==null)

{

DataSet dstReqObj=new DataSet();

Session["ItemData"]=dstReqObj;



//CheckBox deleteChkBxItem = (CheckBox) CurRow.FindControl("del");

colResult=new DataColumn("SNO",Type.GetType("System.Int32")); 

colResult.AutoIncrementSeed=1;

colResult.AutoIncrement=true;

keys[0] = colResult;

dt.Columns.Add(colResult); 

colResult=new DataColumn("Answer",Type.GetType("System.String")); 

dt.Columns.Add(colResult);

colResult=new DataColumn("Value",Type.GetType("System.String")); 

dt.Columns.Add(colResult);

dt.PrimaryKey=keys;

dstReqObj.Tables.Add(dt); 



} 

else

{

dvView=(DataView)Session["ItemData"];



dt=dvView.Table;

}



int i=dt.Rows.Count+1;

if(i<=1)

{

dr=dt.NewRow();





dr[1]=Tbx_ans.Text;

dr[2]=Tbx_defans.Text;

dt.Rows.Add(dr);

DataView dv = new DataView(dt); 

return dv; 

}

else

{

dr=dt.NewRow();

dr[1]=Tbx_ans.Text;

dr[2]=Tbx_defans.Text;

dt.Rows.Add(dr);

DataView dv = new DataView(dt);

return dv;

}

}


Yahoo! India Matrimony: Find your life partneronline.

[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to