DataGrid Row Disappears when click edit??

A

Assimalyst

Hi,

I have a datagrid DataBound with the following code:

private void SampleSearch()
{

// set search strings
int intUserNo = (int)(Session["usrNo"]);
string strPatientCode = patientCodeTxtBx.Text;
DateTime dateProcedureDate = DateTime.Parse(procedureDateTxtBx.Text);

// set parameter values
daSampleAss.SelectCommand.Parameters["@patientCode"].Value =
strPatientCode;
daSampleAss.SelectCommand.Parameters["@procedureDate"].Value =
dateProcedureDate;
daSampleAss.SelectCommand.Parameters["@usrNo"].Value = intUserNo;

daSampleAss.Fill(dsSampleAss1);

DataGrid1.DataBind();
}

Which works OK.

But when I click the 'Edit' link in the first column, the headers
remain but the row disappears. It's code is as follows:

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

DataGrid1 has DataSource = dsSampleAss1.

Any ideas?

Thanks.
 
A

Assimalyst

It seems after much messing that the problem may be to do with the fact
that I have removed the if(!IsPostBack) code from the
DataGrid1.DataBind().

I created a test and it works ok if if(!IsPostBack) is included, and
run from the Page_Load method.

However I want to bnd the datagrid using a button click, in which case
the datagrid does not bind due to if(!IsPostBack) being false. Is there
anyway around this?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top