Dear All Telerik Gurus. I have about 2 years experience of using the radgrid control usually without too much problem. Everytime I click a button to update the row the DataKeyValue is always null. I have either gone mad or I am making a school boy error here. Please see my font end code and serverside code. Any help would be appreciated.
This is the grid above
This is how I am referencing the datakeyvalue but keeps returning null.
Many thanks
Simon
<
telerik:RadGrid
ID
=
"radIssues"
runat
=
"server"
AllowFilteringByColumn
=
"false"
AllowSorting
=
"True"
nItemCommand
=
"radIssues_ItemCommand"
CellSpacing
=
"0"
CssClass
=
"grid-float"
DataSourceID
=
"ldsIssueLog"
ShowStatusBar
=
"True"
Skin
=
"Sitefinity"
Width
=
"70%"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
DataSourceID
=
"ldsIssueLog"
GroupLoadMode
=
"Client"
DataKeyNames
=
"issueID"
ClientDataKeyNames
=
"issueID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"issueID"
HeaderText
=
""
UniqueName
=
"issueID"
Visible
=
"true"
> </
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"issueTitle"
HeaderText
=
"Title"
ReadOnly
=
"True"
SortExpression
=
"issueTitle"
UniqueName
=
"issueTitle"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"issueText"
HeaderText
=
"Issue"
ReadOnly
=
"True"
SortExpression
=
"issueText"
UniqueName
=
"issueText"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"issueDateCreated"
HeaderText
=
"Created Date"
ReadOnly
=
"True"
SortExpression
=
"issueText"
UniqueName
=
"issueDateCreated"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"createdBy"
HeaderText
=
"Created By"
ReadOnly
=
"True"
SortExpression
=
"issueText"
UniqueName
=
"createdBy"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"issueDateAmended"
HeaderText
=
"Amended Date"
ReadOnly
=
"True"
SortExpression
=
"issueText"
UniqueName
=
"issueDateAmended"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"amendedBy"
HeaderText
=
"Amended By"
ReadOnly
=
"True"
SortExpression
=
"issueText"
UniqueName
=
"amendedBy"
></
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderText
=
"Comment"
UniqueName
=
"issueComment"
>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtNote"
runat
=
"server"
InputType
=
"Text"
Rows
=
"2"
Text='<%# Eval("issueComment")%>' TextMode="MultiLine">
</
telerik:RadTextBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Complete"
ItemStyle-Width
=
"100px"
UniqueName
=
"chkComplete"
>
<
ItemTemplate
>
<
input
type
=
"checkbox"
id
=
"chkComplete"
onclick
=
"checkChangedEvent();"
runat
=
"server"
checked='<%# Eval("completed")%>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
a
class
=
"popup-link"
href='dlgAddNewIssue.aspx?issueID=<%# Eval("issueID")%>&instructionID=<%=Int32.Parse(Request.QueryString["instructionID"])%>&panelID=<%= Request.QueryString["panelID"]%>&sale=<%= Request.QueryString["sale"]%>' title="Edit Issue">[Edit] </
a
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
a
class
=
"popup-link"
href='dlgRemoveIssue.aspx?issueID=<%# Eval("issueID")%>&instructionID=<%=Int32.Parse(Request.QueryString["instructionID"])%>&panelID=<%= Request.QueryString["panelID"]%>&sale=<%= Request.QueryString["sale"]%>' title="Remove Issue">[Remove] </
a
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"PushButton"
Text
=
"Completion Note"
CommandName
=
"transfer"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
01.
if
(e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
02.
{
03.
GridDataItem item = e.Item
as
GridDataItem;
04.
// using DataKey
05.
string
id = item.GetDataKeyValue(
"IssueID"
).ToString();
06.
07.
//int issueID;
08.
09.
//var issuesIdCheck = item.GetDataKeyValue("issueID").ToString();
10.
11.
//if (int.TryParse(item["IssueID"].Text, out issueID))
12.
//if (int.TryParse(id, out issueID))
13.
//{
14.
using
(var db =
new
dataDataContext())
15.
{
16.
issue objIssue = db.issues.FirstOrDefault(f => f.issueID ==
int
.Parse(id));
17.
if
(objIssue !=
null
)
18.
{
19.
PostCompletionIssue objCompletionNote =
new
PostCompletionIssue()
20.
{
21.
FK_InstructionID =
int
.Parse(Request.QueryString[
"instructionID"
]),
22.
postCompletionIssueCreatedDate = DateTime.Now,
23.
postCompletionText = objIssue.issueText,
24.
postCompletionTitle = objIssue.issueTitle
25.
};
26.
27.
db.PostCompletionIssues.InsertOnSubmit(objCompletionNote);
28.
db.SubmitChanges();
29.
30.
RadAjaxPanel5.ResponseScripts.Add(String.Format(
"$find('{0}').ajaxRequest();"
,
31.
RadAjaxPanel7.ClientID));
32.
RadAjaxPanel5.Alert(
"Added to completion notes."
);
33.
34.
}
35.
}
36.
}
Many thanks
Simon