"Randy" <> wrote in message
news:E7C40CC6-7F4F-4C40-B723-...
> SPecifically in the gridview_RowDeleting , in the gridview__RowDataBound I
> use e.Row.Cells(0).Text but those do not appear in the intellisense in the
> RowDeleting event.
>
> "Randy" wrote:
>
>> Hi,
>> In the old datagrid control in VS2003 the text in a cell could be
>> accessed
>> by using the following sysntax:
>> e.Item.Cells(1).Text
>>
>> What is the Corresponding code to access the text in a cell of a new
>> gridview control?
>>
>> Thanks for any help
Does this help?
protected void DetailsView1_ItemInserting(object sender,
DetailsViewInsertEventArgs e)
{
string newcat = (string)e.Values["catA"];
if ((newcat == null) || (newcat == ""))
{
LabelFeedback.Text = "Please enter a new category to insert";
e.Cancel = true;
return;
}
// check if this insert already exists:
// 1. copy the items in the Rows collection into an array.
GridView gv = GridView1;
int idx = gv.SelectedIndex;
GridViewRow gvw = gv.SelectedRow;
GridViewRow[] rowArray = new GridViewRow[gv.Rows.Count];
gv.Rows.CopyTo(rowArray, 0);
// 2. iterate though the array and display the value in the first cell of
the row.
int j = -1;
foreach (GridViewRow row in rowArray)
{
j++;
if (newcat == row.Cells[2].Text)
{
LabelFeedback.Text = "This category already exists";
e.Cancel = true;
break;
}
}
// if all ok to go, insert the trimmed value:
e.Values["catA"] = newcat;
}
|