Hi
What it should do:
I want put a button in every empty cell in the datagrid and when that button is clicked it puts a time stamp in the database in that specific cell of data. Thus when the datagrid is updated that cell will now have a timestamp instead of a button.
What it does now:
When I check if the cell is empty "if (e.Item.Cells[4].Text =="")", even if the cell has data in it it still puts a button in it. So the end result is that the cell has both a timestamp and a button.
When I add the following butReceive.Attributes("onclick") = "javascript:TimeStamp()";
Compiler Error Message: CS0118: 'System.Web.UI.WebControls.WebControl.Attributes' denotes a 'property' where a 'method' was expected.
When I click the button I want it to go to the function TimeStamp.
Once it goes to the TimeStamp function I need to know the name of the column the cell was in and also the "pas_no" this is a unique id of the row so I can add the timestamp to the database.
Please can you help
<%# DataBinder.Eval(Container.DataItem, "ts_received") %>
<%# DataBinder.Eval(Container.DataItem, "ts_profess_check") %>
<%# DataBinder.Eval(Container.DataItem, "ts_label_dispense") %>
<%# DataBinder.Eval(Container.DataItem, "ts_awaiting_check") %>
<%# DataBinder.Eval(Container.DataItem, "ts_completed") %>
<%# DataBinder.Eval(Container.DataItem, "ts_query") %>
void UpdateImage(Object sender, DataGridItemEventArgs e)
{
if((e.Item.ItemType != ListItemType.Header))
{
Button butReceive = new Button();
butReceive.Text="Update";
butReceive.Attributes("onclick") = "javascript:TimeStamp()";
Button butPCheck = new Button();
butPCheck.Text="Update";
Button butDispense = new Button();
butDispense.Text="Update";
Button butACheck = new Button();
butACheck.Text="Update";
Button butComplete = new Button();
butComplete.Text="Update";
Button butQuery = new Button();
butQuery.Text="Update";
//but.Attributes("onclick") = "UpdateImage";
if (e.Item.Cells[4].Text =="")
{
e.Item.Cells[4].Controls.Add(butReceive);
}
if (e.Item.Cells[5].Text =="")
{
e.Item.Cells[5].Controls.Add(butPCheck);
}
if (e.Item.Cells[6].Text =="")
{
e.Item.Cells[6].Controls.Add(butDispense);
}
if (e.Item.Cells[7].Text =="")
{
e.Item.Cells[7].Controls.Add(butACheck);
}
if (e.Item.Cells[8].Text =="")
{
e.Item.Cells[8].Controls.Add(butComplete);
}
if (e.Item.Cells[9].Text =="")
{
e.Item.Cells[9].Controls.Add(butQuery);
}
}
void TimeStamp(Object sender, DataGridItemEventArgs e)
{
//Add a timestamp to that cell in the database
}