Getting a datalist row

D

David

Hi all,

I have a datalist that I can put into edit then into update.

In my update datalist function, I call another function passing the
DataListCommandEventArgs which actually does the update work instead of
relying on the update (mainly because I need to control the update from
another event).

The problem I have is when I click edit, then click edit on another row
(without cancelling or updating the first row) I want to update the first
edit row before putting the next row into edit mode. This is where I call
the function that I pass the DataListCommandEventArgs to.

It is easier to explain in code...

protected void DefectListDL_EditCommand(object source,
DataListCommandEventArgs e)
{
if (DefectListDL.EditItemIndex >= 0)
{
UpdateDefectDL(e);
}


DefectListDL.EditItemIndex = e.Item.ItemIndex;

BuildIncomingDefects();
}


As you can see, when I click edit, I check if something is already being
editted, then I want to call the update function.

However, my problem is that when I call the UpdateDefectDL, any time I try
to reference an item, it is wanting to reference the row based on the
current ItemIndex rather than the current EditItemIndex.

This is fine when I do a save on the current row, but not when I click to
edit another row.

Simplistically, if in my updatedefectdl function...

private void UpdateDefectDL(DataListCommandEventArgs e)
{

string MyID = ((TextBox)e.Item.FindControl("DBRowIDTB")).Text

}

the MyID will attempt to get the item from the current ItemIndex, however, I
cannot see any way to get a specific row from the datalist. Not even if I
reference the DL directly.

(I have done the same with a gridview and that works well... I just cannot
make it work with the DataList)

Any ideas?

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
J

Jeff Johnson

It works... but the question still applies to C#...

Only because you happen to be using C#.
yeah, I am trying to read an ASP.NET Textbox control, but as far as I am
aware, the datalist is a generic .NET control and I was trying to read it
in a generic way.

This control is located in System.Web.UI.WebControls. I don't see what in
any way suggests that it's a "generic .NET control."

I'm not trying to chase you away; I'm trying to suggest the place where
you're likely to get the most help, and that's an ASP.NET group when your
topic is ASP.NET programming. Language is incidental in this case.
 

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

Top