I recently ran into an issue where I was unable to set a breakpoint on a custom application page I had developed, thus making it really difficult to track down errors. Typically, these pages are stored in the 12 hive in the layouts directory. Debugging them is usually hit and miss for me, sometimes it works and other times I get the generic breakpoint could not be hit, symbols could not be loaded error.

I did a bit of research and found a great article by Sowmyan on his blog. Check it out here. To summarize, you need to make sure that in the web.config for your SharePoint app, you have the compilation tag debug property set to true.

<compilation batch="false" debug="true">

This worked great for me. However, I did so a big of digging to determine what exactly is the impact of changing this to true. I found a great article that summarizes it here. The bottom line is that you may want to consider switching it back to false once your app has been built, tested and is ready for production usage.

Tagged with:  

In this post, I’m going to talk a little bit about how to access specific controls within a RadGrid while that grid is in edit mode. There are several reasons you may want to do this:

  • You might need to set some defaults for the control.
  • You want to perform some calculation and output some default value to the control.
  • You may need to change the attributes of a control (color, font etc).

In order to achieve any of the above, we need a way to get access to the controls while in edit mode.

To begin, you’ll need to add the ItemDataBound event to your grid, so that when we’re in edit mode and the items are being bound, we can perform our custom code.

1
OnItemDataBound="RadGrid1_ItemDataBound"

Next, add the method to handle the ItemDataBound event for the grid as follows:

1
2
3
4
5
6
7
8
9
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if ((e.Item is GridEditableItem) &amp;&amp; (e.Item.IsInEditMode))
    {
        GridEditableItem edititem = (GridEditableItem)e.Item;
        TextBox txtbx = (TextBox)edititem["ColumnUniqueName"].Controls[0];
        txtbx.Text = "";
    }
}

The above code is pretty straight forward. We check first to see if we’re in edit mode, because we don’t want to be performing this code during any other time. We create a GridEditableItem object so that we can talk to the controls of the item we’re currently editing. And finally, if it’s a textbox we’re dealing with, create a TextBox object and using the unique name you’ve assigned that column, we can access the control within it.

Now that you have a TextBox object, you can access all the properties and methods of that object as you normally would.

If the control in question is a checkbox, it’s not much different:

1
2
3
4
5
CheckBox cb = (CheckBox)edititem["ColumnUniqueName"].Controls[0];
 
if (cb.Checked) {
    // perform some custom code
}
Tagged with: