views:

34

answers:

2

I want to access controls and update database with their value. Notice using following code:

void grdList_UpdateCommand(object source, GridCommandEventArgs e)
{
        string str = ((RadTextBox)e.Item.FindControl("txtLookupItemValue")).Text;
}

I have access to control txtLookupItemValue, but it contains before-edit content, not actual value that user has entered.

+1  A: 

Hi, have you tried setting the string during the edit event:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{

   string str = ((RadTextBox)e.Item.FindControl("txtLookupItemValue")).Text;

}

Then update your DB and rebind the gridview to display the updated row.

Matt
@Matt, I have tested value of `str1` in debug mode. It just contains before-edit-value.
afsharm
A: 

I think you can get the value when the grid is updating. E.g:

protected void GridUpdating(object sender, GridViewUpdateEventArgs e)
{
string str = (RadTextBox)this.yourGridviewName.Rows[e.RowIndex].FindControl("txtLookupItemValue").Text;
}

Then add this to the gridview on the aspx:

OnRowUpdating="GridUpdating"
adrianos
I'm using Telerik's RadGrid. It does not have any event named Updating.
afsharm