I have an issue and I have been banging my head against the wall in solving this, This is some very basic stuff that is just not working for me. My Page Markup is as follows
Now I have created the following user control by looking at the demos page
My problem is with the SQLDataSource Update command.... the ID passes by just fine but all the other values go in as NULL... I have confirmed this by running the profiler.
SQL PROFILER
"exec sp_executesql N'UPDATE [Documents] SET [Name] = @Name WHERE [ID]=@ID',N'@Name nvarchar(4000),@original_ID bigint,@original_Name nvarchar(4000)',@Name=NULL,@original_ID=179,@original_Name=NULL"
This is not worked for me at all from very beginning and I am very frustrated by this. Can any body help me with this. Thanks
Junaid Mufti
Synistosa Technologies
http://synistosa.com
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
CssClass
=
"RadGrid"
GridLines
=
"None"
wallowpaging
=
"True"
PageSize
=
"20"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
ShowStatusBar
=
"True"
AllowAutomaticDeletes
=
"True"
AllowAutomaticUpdates
=
"True"
DataSourceID
=
"SqlDataSource1"
OnItemDeleted
=
"RadGrid1_ItemDeleted"
OnItemInserted
=
"RadGrid1_ItemInserted"
OnItemUpdated
=
"RadGrid1_ItemUpdated"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnPreRender
=
"RadGrid1_PreRender"
CellSpacing
=
"0"
OnItemCreated
=
"RadGrid1_ItemCreated"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
PagerStyle
Mode
=
"Slider"
/>
<
ClientSettings
>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
/>
</
ClientSettings
>
<
AlternatingItemStyle
/>
<
MasterTableView
CommandItemDisplay
=
"Top"
Name
=
"Documents"
AutoGenerateColumns
=
"False"
Width
=
"100%"
DataSourceID
=
"SqlDataSource1"
DataKeyNames
=
"ID"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"ID"
Name
=
"Sections"
DataSourceID
=
"SqlDataSource2"
runat
=
"server"
>
<%-- Sql DataSource 3 --%>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"ID"
Name
=
"Requirements"
DataSourceID
=
"SqlDataSource3"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"DocumentSectionID"
MasterKeyField
=
"ID"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
SortExpression
=
"ID"
UniqueName
=
"ID"
Visible
=
"false"
FilterControlAltText
=
"Filter Name column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DocNameReqID"
SortExpression
=
"DocNameReqID"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"ID"
UniqueName
=
"DocNameReqID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Category"
SortExpression
=
"Category"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"Category"
UniqueName
=
"Category"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Text"
SortExpression
=
"Text"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"Text"
UniqueName
=
"Text"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Highlight"
HeaderText
=
"Highlight"
SortExpression
=
"Highlight"
UniqueName
=
"Highlight"
Visible
=
"false"
FilterControlAltText
=
"Filter Highlight column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Keyword"
SortExpression
=
"Keyword"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"Keyword"
UniqueName
=
"Keyword"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"ibtnEdit"
runat
=
"server"
CommandName
=
"EditRecord"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>'
AlternateText="Edit" ImageUrl="~/Images/edit.gif" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this record?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"ID"
>
<
ItemStyle
HorizontalAlign
=
"Center"
CssClass
=
"MyImageButton"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<%-- Sql DataSource 3 --%>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"DocumentID"
MasterKeyField
=
"ID"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
SortExpression
=
"ID"
UniqueName
=
"ID"
Visible
=
"false"
FilterControlAltText
=
"Filter Name column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
DataTextField
=
"Name"
HeaderText
=
"Name"
CommandName
=
"RequirementLink"
ButtonType
=
"LinkButton"
>
</
telerik:GridButtonColumn
>
<
telerik:GridBoundColumn
DataField
=
"Text"
SortExpression
=
"Text"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"Req Description"
UniqueName
=
"Text"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PageNo"
SortExpression
=
"PageNo"
FilterControlAltText
=
"Filter Text column"
HeaderText
=
"Page"
UniqueName
=
"Text"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this record?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"ID"
>
<
ItemStyle
HorizontalAlign
=
"Center"
CssClass
=
"MyImageButton"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"ID"
></
telerik:GridSortExpression
>
</
SortExpressions
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
SortExpression
=
"ID"
UniqueName
=
"ID"
Visible
=
"true"
FilterControlAltText
=
"Filter Name column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FileName"
SortExpression
=
"FileName"
FilterControlAltText
=
"Filter FileName column"
HeaderText
=
"File Name"
UniqueName
=
"FileName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DocFormat"
FilterControlAltText
=
"Filter DocFormat column"
HeaderText
=
"Format"
SortExpression
=
"DocFormat"
UniqueName
=
"DocFormat"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Size"
FilterControlAltText
=
"Filter Size column"
HeaderText
=
"Size (KB)"
SortExpression
=
"Size"
UniqueName
=
"Size"
DataType
=
"System.Double"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"TimeStamp"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter TimeStamp column"
HeaderText
=
"Time Stamp"
SortExpression
=
"TimeStamp"
UniqueName
=
"TimeStamp"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ParsedTime"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter ParsedTime column"
HeaderText
=
"Parsed Time"
SortExpression
=
"ParsedTime"
UniqueName
=
"ParsedTime"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Download"
Text
=
"Download"
ImageUrl
=
"~/Images/download.png"
>
</
telerik:GridButtonColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this record?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"ID"
>
<
ItemStyle
HorizontalAlign
=
"Center"
CssClass
=
"MyImageButton"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
UserControlName
=
"EmployeeDetailsCS.ascx"
EditFormType
=
"WebUserControl"
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_WebBlue"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DocumentParsingConnectionString %>"
SelectCommand="SELECT [ID],[Name], [FileName], [DocType], [DocFormat], [DocRefNo], [Title], [Size], [Version], [TimeStamp],[ParsedTime] FROM [Documents]"
UpdateCommand="UPDATE [Documents] SET [Name] = @Name WHERE [ID]=@ID" DeleteCommand="DELETE FROM [Documents] WHERE [ID] = @ID"
OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges">
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Name"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"original_ID"
Type
=
"Int64"
/>
<
asp:Parameter
Name
=
"original_Name"
Type
=
"String"
/>
</
UpdateParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int64"
/>
</
DeleteParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DocumentParsingConnectionString %>"
SelectCommand="SELECT [ID],[PageNo],[Name],SUBSTRING ([Text], 0 , 255 ) AS [Text] FROM [DocumentSections] WHERE DocumentID=@DocumentID"
DeleteCommand="DELETE FROM [DocumentSections] WHERE [ID] = @ID">
<
SelectParameters
>
<
asp:SessionParameter
SessionField
=
"DocumentID"
Name
=
"DocumentID"
Type
=
"Int64"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int64"
/>
</
DeleteParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DocumentParsingConnectionString %>"
SelectCommand="SELECT [DocumentSections].[Name] + CONVERT(varchar(250), ROW_NUMBER() OVER (ORDER BY [Requirements].[ID])) AS DocNameReqID, [DocumentSections].[DocumentID] AS [DocumentID], [DocumentSections].[Name] AS [DocumentSectionName], [Requirements].[ID],[Requirements].[Category],[Requirements].[Text], [Requirements].[Keyword], [Requirements].[Highlight] FROM [Requirements] INNER JOIN [DocumentSections] ON [Requirements].[DocumentSectionID] = [DocumentSections].[ID] WHERE [Requirements].[DocumentSectionID]=@DocumentSectionID"
DeleteCommand="DELETE FROM [Requirements] WHERE [ID] = @ID">
<
SelectParameters
>
<
asp:SessionParameter
SessionField
=
"DocumentSectionID"
Name
=
"DocumentSectionID"
Type
=
"Int64"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int64"
/>
</
DeleteParameters
>
</
asp:SqlDataSource
>
Now I have created the following user control by looking at the demos page
<
table
id
=
"Table3"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Name:
</
td
>
<
td
>
<
asp:HiddenField
ID
=
"hfID"
runat
=
"server"
Value='<%# DataBinder.Eval( Container, "DataItem.Name" ) %>'></
asp:HiddenField
>
<
asp:TextBox
ID
=
"TextBox7"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.Name" ) %>'>
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
FileName:
</
td
>
<
td
>
<
asp:TextBox
ID
=
"TextBox8"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.FileName") %>'
TabIndex="1">
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
DocType:
</
td
>
<
td
>
<
asp:TextBox
ID
=
"TextBox9"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.DocType") %>'
TabIndex="2">
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
DocFormat:
</
td
>
<
td
>
<
asp:TextBox
ID
=
"TextBox5"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.DocFormat") %>'
TabIndex="2">
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
>
DocRefNo:
</
td
>
<
td
>
<
asp:TextBox
ID
=
"TextBox10"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.DocRefNo") %>'
TabIndex="2">
</
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
colspan
=
"2"
>
<
asp:Button
ID
=
"btnUpdate"
Text
=
"Update"
runat
=
"server"
CommandName
=
"Update"
Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'
onclick="btnUpdate_Click">
</
asp:Button
>
<
asp:Button
ID
=
"btnInsert"
Text
=
"Insert"
runat
=
"server"
CommandName
=
"PerformInsert"
Visible='<%# DataItem is Telerik.Web.UI.GridInsertionObject %>'></
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
>
</
td
>
</
tr
>
</
table
>
My problem is with the SQLDataSource Update command.... the ID passes by just fine but all the other values go in as NULL... I have confirmed this by running the profiler.
SQL PROFILER
"exec sp_executesql N'UPDATE [Documents] SET [Name] = @Name WHERE [ID]=@ID',N'@Name nvarchar(4000),@original_ID bigint,@original_Name nvarchar(4000)',@Name=NULL,@original_ID=179,@original_Name=NULL"
This is not worked for me at all from very beginning and I am very frustrated by this. Can any body help me with this. Thanks
Junaid Mufti
Synistosa Technologies
http://synistosa.com