Hi,
I have a RadGrid on my web page in which I am implementing only "Add records" functionality.
When I try to click on "Add" button, nothing happens (it do not show panel to add records in it)
Please reply what mistake I am doing in my code.
Below is the .aspx (say "Default.aspx" page) code:
<
telerik:RadMultiPage
ID
=
"RadMultiPage4"
runat
=
"server"
SelectedIndex
=
"0"
Width
=
"100%"
>
<
telerik:RadPageView
ID
=
"RadPageView3"
runat
=
"server"
Width
=
"100%"
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel3"
runat
=
"server"
>
<
asp:label
ID
=
"Label2"
runat
=
"server"
style
=
"display: none;"
/>
<
telerik:RadGrid
ID
=
"RGGSTChat"
runat
=
"server"
AutoGenerateColumns
=
"false"
ShowStatusBar
=
"true"
EnableEmbeddedSkins
=
"true"
Skin
=
"Outlook"
OnNeedDataSource
=
"rggstChat_NeedDataSource"
OnInsertCommand
=
"RGGSTChat_InsertCommand"
>
<
mastertableview
commanditemdisplay
=
"Top"
autogeneratecolumns
=
"false"
datakeynames
=
"ChatID"
insertitempageindexaction
=
"ShowItemOnCurrentPage"
ShowFooter
=
"True"
>
<
CommandItemSettings
AddNewRecordText
=
"New"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ChatID"
HeaderText
=
"Id"
UniqueName
=
"ChatID"
SortExpression
=
"ChatID"
Visible
=
"false"
>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
<
FooterStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ChatTo"
HeaderText
=
"To"
UniqueName
=
"ChatTo"
SortExpression
=
"ChatTo"
>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
<
FooterStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ChatCc"
HeaderText
=
"Cc"
UniqueName
=
"ChatTo"
SortExpression
=
"ChatTo"
>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
<
FooterStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ChatSubject"
HeaderText
=
"Subject"
UniqueName
=
"ChatSubject"
SortExpression
=
"ChatSubject"
>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
<
FooterStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ChatContent"
HeaderText
=
"Content"
UniqueName
=
"ChatContent"
SortExpression
=
"ChatContent"
>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
<
FooterStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
ButtonType
=
"ImageButton"
/>
</
EditFormSettings
>
<
PagerStyle
AlwaysVisible
=
"True"
PageSizeControlType
=
"RadComboBox"
/>
</
mastertableview
>
</
telerik:RadGrid
>
</
telerik:RadAjaxPanel
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
C# code:
protected
void
rggstChat_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
Label GUID = fvIPRForm.FindControl(
"TempGUID"
)
as
Label;
// RequestID
RadGrid RGGSTChat = fvIPRForm.FindControl(
"RGGSTChat"
)
as
RadGrid;
if
(!
string
.IsNullOrEmpty(Request.QueryString[
"RequestID"
]))
{
GUID.Text = Request.QueryString[
"RequestID"
];
}
if
(
string
.IsNullOrEmpty(GUID.Text))
{
GUID.Text = Session[
"GUID"
].ToString();
}
DataTable dt = IPRRequest.SelectChatData(
new
Guid(GUID.Text));
RGGSTChat.DataSource = dt;
Response.Write(
"Page_Load Error. Reason: "
+ GUID.Text);
}
protected
void
RGGSTChat_InsertCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item
as
GridEditableItem;
Label requestID = fvIPRForm.FindControl(
"TempGUID"
)
as
Label;
string
chat_to = (item[
"lblTo"
].Controls[1]
as
Label).Text;
string
chat_cc = (item[
"lblCc"
].Controls[2]
as
Label).Text;
string
chat_subj = (item[
"lblSubject"
].Controls[3]
as
Label).Text;
string
chat_Content = (item[
"lblContent"
].Controls[4]
as
Label).Text;
string
loginUser = AD_Guard.Checker(Session[
"LoginUser"
].ToString()) +
""
;
IPRRequest.InsertChatData(
new
Guid(requestID.Text), chat_to, chat_cc, chat_subj, chat_Content, loginUser);
}
This is the .dll (say "abc.cs" page) code, this .dll is used for DB connection:
public
static
DataTable SelectChatData(Guid requestID)
{
Data data =
new
Data();
Dictionary<
string
,
object
> input =
new
Dictionary<
string
,
object
>()
{
{
"@RequestId"
, requestID}
//{"@ChatID", null},
//{"@ChatTo", chatTo},
//{"@ChatCc", chatCC},
//{"@ChatSubject", chatSubj},
//{"@ChatContent", chatMsg}
};
DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure,
"Invoice.usp_tbl_Request_Chat_Select"
, input);
return
dt;
}
public
static
DataTable InsertChatData(Guid requestID,
string
chat_to,
string
chat_cc,
string
chat_subj,
string
chat_Content,
string
loginUser)
{
Data data =
new
Data();
Dictionary<
string
,
object
> input =
new
Dictionary<
string
,
object
>()
{
{
"@RequestID"
, requestID},
{
"@ChatTo"
, chat_to},
{
"@ChatCc"
, chat_cc},
{
"@ChatSubject"
, chat_subj},
{
"@ChatContent"
, chat_Content},
{
"@CreatedBy"
, loginUser},
{
"@CreatedDate"
, DateTime.Now.ToString()}
};
DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure,
"[Invoice].[usp_tbl_Request_Chat_Insert]"
, input);
return
dt;
}