H
Hai Nguyen
I'm building a form so that customer can fill in their data (with a lot of texboxes). I decided to use datagrid. I don't know if I'm on the right track. I was able to build a array of datagrids programmactically. Here is my situation.
From : mm/dd/yy
To: mm/dd/yy
Fill (button)
Grid1 (all of these grids are built programmatcally and added into a placeholder)
Grid2
Grid3
....
Because there are 2 columns From and To
From : mm/dd/yy (<--- user will fill here) (**)
To: mm/dd/yy (<--- user will fill here) (***)
Grid1
From To A B C
blank blnk (user will fill here) (user will fill here) (user will fill here)
.....
I want to assist user to fill the date they enter at (**) into the From column of the grid for them. I don't know what to do. I tried to write a piece of code for the button fill above but I failed.
Help me if you can. Thanks
protected System.Web.UI.WebControls.DataGrid[] grids;
public void fill (object sender, System.EventArgs e)
{
string from = frombox.Text;
string to = tobox.Text;
foreach(DataGrid grid in grids)
{
foreach(DataGridItem item in grid.Items)
{
Response.Write("Found");
//TextBox tb = (TextBox)item.Cells[1].FindControl("answerbox");
//string str = tb.Text;
//ls.Add(str);
}
}
}
Errror
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 214: Response.Write("Control not found");
Line 215: }*/
Line 216: foreach(DataGrid grid in grids)
Line 217: {
Line 218: foreach(DataGridItem item in grid.Items)
From : mm/dd/yy
To: mm/dd/yy
Fill (button)
Grid1 (all of these grids are built programmatcally and added into a placeholder)
Grid2
Grid3
....
Because there are 2 columns From and To
From : mm/dd/yy (<--- user will fill here) (**)
To: mm/dd/yy (<--- user will fill here) (***)
Grid1
From To A B C
blank blnk (user will fill here) (user will fill here) (user will fill here)
.....
I want to assist user to fill the date they enter at (**) into the From column of the grid for them. I don't know what to do. I tried to write a piece of code for the button fill above but I failed.
Help me if you can. Thanks
protected System.Web.UI.WebControls.DataGrid[] grids;
public void fill (object sender, System.EventArgs e)
{
string from = frombox.Text;
string to = tobox.Text;
foreach(DataGrid grid in grids)
{
foreach(DataGridItem item in grid.Items)
{
Response.Write("Found");
//TextBox tb = (TextBox)item.Cells[1].FindControl("answerbox");
//string str = tb.Text;
//ls.Add(str);
}
}
}
Errror
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 214: Response.Write("Control not found");
Line 215: }*/
Line 216: foreach(DataGrid grid in grids)
Line 217: {
Line 218: foreach(DataGridItem item in grid.Items)