This is a migrated thread and some comments may be shown as answers.

confirmtext value is populating incorreclty from itemdatabound

0 Answers 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
areen
Top achievements
Rank 1
areen asked on 26 May 2011, 10:38 PM
i'm having a strange issue. My code builds and executes fine, but when i click the release button to execute the confirmtext function, the string in the confirmtext value is in the wrong place. the text for each channelid should correspond to the channel id for the dataitem. instead the text is off by one. for example:

row 1    
releaseButton.confirmtext     
should be: channel 1 on 1.1.1.1 
actual: default text from grid definition

row 2
releaseButton.confirmtext     
should be: channel 2 on 1.1.1.1 
actual: channel 1 on 1.1.1.1 

row 3
releaseButton.confirmtext     
should be: channel 3 on 1.1.1.1 
actual: channel 2 on 1.1.1.1 

etc.

where am i going wrong?
protected void RadGrid1_ItemDataBound(object source, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        // retrieve the original values from the database
        DataSet dsOriginal = new DataSet();
        string strErrorText = string.Empty;
  
        GridDataItem dataItem = (GridDataItem)e.Item;
        string strChannelId = dataItem.GetDataKeyValue("ChannelId").ToString(); // RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["ChannelId"].ToString();
  
        this.GetChannelDetail(out dsOriginal, out strErrorText, strChannelId);
        DataTable dtOriginal = dsOriginal.Tables["Channel"];
        DataRow drOriginal = dtOriginal.Rows[0];
  
        GridColumn gridColumn = (GridColumn)dataItem.OwnerTableView.Columns.FindByUniqueName("columnRelease");
        (gridColumn as GridButtonColumn).ConfirmText = string.Format("Are you sure you want to release channel {0} on FMIS Server {1}?", Convert.ToString(drOriginal.ItemArray[2]), Convert.ToString(drOriginal.ItemArray[1]));
    }
}

No answers yet. Maybe you can help?

Tags
Grid
Asked by
areen
Top achievements
Rank 1
Share this question
or