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

any idea why my fields parameter doesn't write to table?

2 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 2
Darren asked on 14 Jan 2009, 11:48 AM
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Delete"
        { 
            string ActionType = "DELETE"
            string Username = Session["Username"].ToString(); 
            string ServiceTypeName = "Website"
            string ServiceName; 
            string Fields; 
            string DateInserted = DateTime.Now.TimeOfDay.ToString(); 
 
            //Setup parameters from RadGrid columns 
            GridDataItem dataformItem = (GridDataItem)e.Item; 
            DataBoundLiteralControl txtbxClientId = (DataBoundLiteralControl)dataformItem["Client"].Controls[0]; 
            string ClientId = txtbxClientId.Text; 
            DataBoundLiteralControl txtbxServerId = (DataBoundLiteralControl)dataformItem["Server"].Controls[0]; 
            string ServerId = txtbxServerId.Text; 
            TableCell txtbxWebsiteUrl = (TableCell)dataformItem["WebsiteUrl"]; 
            string WebsiteUrl = txtbxWebsiteUrl.Text; 
            TableCell txtbxLogFilePath = (TableCell)dataformItem["LogFilePath"]; 
            string LogFilePath = txtbxLogFilePath.Text; 
            TableCell txtbxBandWidthCost = (TableCell)dataformItem["BandWidthCost"]; 
            string BandWidthCost = txtbxBandWidthCost.Text; 
            DataBoundLiteralControl txtbxChargeTypeId = (DataBoundLiteralControl)dataformItem["Charge"].Controls[0]; 
            string ChargeTypeId = txtbxChargeTypeId.Text; 
            TableCell txtbxAmount = (TableCell)dataformItem["Amount"]; 
            string Amount = txtbxAmount.Text; 
            TableCell txtbxBandWidthLimit = (TableCell)dataformItem["BandWidthlimit"]; 
            string BandWidthLimit = txtbxBandWidthLimit.Text; 
            CheckBox chkbxSqlDataBase = (CheckBox)dataformItem["SqlDatabase"].Controls[0]; 
            if (chkbxSqlDataBase.Checked == true
            { 
                chkbxSqlDataBase.Text = "1"
            } 
            else 
            { 
                chkbxSqlDataBase.Text = "0"
            } 
            string SqlDataBase = chkbxSqlDataBase.Text; 
            TableCell txtbxSqlMbLimit = (TableCell)dataformItem["SqlMbLimit"]; 
            string SqlMbLimit = txtbxSqlMbLimit.Text; 
            TableCell txtbxMbCharge = (TableCell)dataformItem["MbCharge"]; 
            string MbCharge = txtbxMbCharge.Text; 
 
            //Setup concatanated Fields parameter. 
            Fields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10}", ClientId, ServerId, WebsiteUrl, LogFilePath, BandWidthCost, ChargeTypeId, Amount, BandWidthLimit, SqlDataBase, SqlMbLimit, MbCharge); 
            ServiceName = WebsiteUrl; 
 
            //Execute Audit SP and pass through parameters 
            //LINQ 
            cknetispservicesDataContext db = new cknetispservicesDataContext(); 
            var testDs = db.spAudit(ActionType, Username, ServiceTypeName, ServiceName, Fields, Convert.ToDateTime(DateInserted)); 
        } 
    } 
 
Any idea why my sp  writes everything to my table in the database except for the "Fields" param?
The SP is fine i'm positive.
I had a breakpoint and i can see that all the information is there and the string is concatenated correctly.
I even ran a SQL profiler and can see the fields string in the stored procedure but still nothing is written to the fields column, other coumns are being written to perfectly.

2 Answers, 1 is accepted

Sort by
0
Darren
Top achievements
Rank 2
answered on 15 Jan 2009, 09:03 AM
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Delete"
        { 
            string ActionType = "DELETE"
            string Username = Session["Username"].ToString(); 
            string ServiceTypeName = "Client"
            string ServiceName; 
            string Fields; 
            string DateInserted = DateTime.Now.TimeOfDay.ToString(); 
 
            //Setup parameters from RadGrid 
            GridDataItem editformItem = (GridDataItem)e.Item; 
            TableCell txtbxClientName = (TableCell)editformItem["ClientName"]; 
            string ClientName = txtbxClientName.Text; 
            TableCell txtbxEmailAddress = (TableCell)editformItem["EmailAddress"]; 
            string EmailAddress = txtbxEmailAddress.Text; 
            TableCell txtbxContactNumber = (TableCell)editformItem["ContactNumber"]; 
            string ContactNumber = txtbxContactNumber.Text; 
            TableCell txtbxContactName = (TableCell)editformItem["ContactName"]; 
            string ContactName = txtbxContactName.Text; 
 
            //Setup concatanated Fields parameter. 
            Fields = string.Format("{0};{1};{2};{3}", ClientName, EmailAddress, ContactNumber, ContactName); 
            ServiceName = ClientName; 
 
            //Execute Audit SP and pass through parameters 
            //LINQ 
            cknetispservicesDataContext db = new cknetispservicesDataContext(); 
            var testDs = db.spAudit(ActionType, Username, ServiceTypeName, ServiceName, Fields, Convert.ToDateTime(DateInserted)); 
        } 
    } 

Interesting, i found this code to work perfectly. The only difference is that there are no "DataBoundLiteralControl". This is leading me to believe that thats where the problem is. I changed the "DataBoundLiteralControl" to "TableCell" but then the string is empty...
0
Darren
Top achievements
Rank 2
answered on 15 Jan 2009, 09:25 AM
ok fixed it.
All the DataBoundLiteralControl i changed to Label. And within the aspx i added a label control. Used the Findcontrol() method and all seems well.
Tags
Grid
Asked by
Darren
Top achievements
Rank 2
Answers by
Darren
Top achievements
Rank 2
Share this question
or