Hi,
I am using RAD Grid in sharepoint 2010. I have added the insercommand and when i click on save in the grid, i am getting "object reference not set to instance of object error".
Below is the code i have used:
In the Insercommand code, values is coming as null.
How to fix this?
Thanks
I am using RAD Grid in sharepoint 2010. I have added the insercommand and when i click on save in the grid, i am getting "object reference not set to instance of object error".
Below is the code i have used:
<
div
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
EnableViewState
=
"true"
ShowStatusBar
=
"true"
ShowFooter
=
"True"
onitemcommand
=
"RadGrid1_ItemCommand"
ondeletecommand
=
"RadGrid1_DeleteCommand"
oninsertcommand
=
"RadGrid1_InsertCommand"
onupdatecommand
=
"RadGrid1_UpdateCommand"
onneeddatasource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
DataKeyNames
=
"Title"
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
CommandItemDisplay
=
"TopAndBottom"
CommandItemSettings-AddNewRecordText
=
"Add New Item"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this product?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
ConfirmDialogHeight
=
"100px"
ConfirmDialogWidth
=
"220px"
>
</
telerik:GridButtonColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Title"
HeaderText
=
"Product Number"
UniqueName
=
"ProductNumber"
Visible
=
"true"
>
<
InsertItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadtxtPrdNumber"
runat
=
"server"
Text='<%# Bind("Title") %>' >
</
telerik:RadTextBox
>
</
InsertItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadtxtPrdNumber"
runat
=
"server"
Text='<%# Eval("Title") %>' >
</
telerik:RadTextBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadtxtPrdNumber"
ReadOnly
=
"true"
runat
=
"server"
Text='<%# Eval("Title") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
</
ClientSettings
>
</
telerik:RadGrid
>
<
asp:Button
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Submit"
onclick
=
"btnSubmit_Click"
/>
</
div
>
protected
void
RadGrid1_InsertCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item
as
GridEditableItem;
Hashtable values =
new
Hashtable();
item.ExtractValues(values);
string
ti = values[
"Title"
].ToString();
}
In the Insercommand code, values is coming as null.
How to fix this?
Thanks