This is a migrated thread and some comments may be shown as answers.

Link Button on Data Grid populated from an ArrayList

3 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 26 Jan 2010, 10:58 PM
Hello

I have a radgrid configured to return results based on an ArrayList. The results are a list of file names, and are displayed correctly. I would like to configure it, so when I click on one of the items in the grid a peice of server side (c#) code is executed. I have done this in other grids where they are bound to SQL, but I can't find out how to pass in the data from the link into the server side code. In other grids, I pass it in like below, but because the columns are automatic and it is an ArrayList, this seems more difficult, any suggestion would be welcomed.

 

<telerik:GridTemplateColumn meta:resourcekey="ColumnSubject">

 

 

<ItemTemplate>

 

 

<asp:LinkButton runat="server" ID="btnShowEmailPreview" Width="200px" CommandName="RowClick" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ExecutedActionLogID")%>'

 

 

><%#DataBinder.Eval(Container.DataItem, "Subject")%></asp:LinkButton>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

Regards

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jan 2010, 09:14 AM
Hello Danny,

Could you specify where the piece of server-side code is coming from? From the database, or you have it in code-behind somewhere?

Thanks. 

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Danny
Top achievements
Rank 1
answered on 05 May 2010, 05:10 PM
Sorry for the delay in replying.

Here is the code of the grid. I would like to pass the DataField from the ArrayList as a command argument.

 

 

<telerik:RadGrid ID="rgAttachments" Width="100.7%" OnItemCommand="rgAttachments_ItemCommand" runat="server">

 

 

 

<MasterTableView>

 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn DataField="" UniqueName="AttachmentName" HeaderText="MyHeaderText">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridTemplateColumn UniqueName="AttachName" DataField="" meta:resourcekey="ColumnSubject">

 

 

 

<ItemTemplate>

 

 

 

<asp:LinkButton runat="server" ID="btnDownloadAttachment" Width="200px" CommandName="RowClick" CommandArgument=""

 

 

 

>Download</asp:LinkButton>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

</Columns></MasterTableView>

 

 

 

</telerik:RadGrid>

 

 

 

</telerik:RadPageView>

 

 

 

</telerik:RadMultiPage>

Here is the c# code

 

 

 

protected void rgAttachments_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

 

if (e.CommandName == "RowClick")

 

{

{

 

 

 

String AttachmentName = e.CommandArgument.ToString();

 

 

 

}
}

 

0
Tsvetoslav
Telerik team
answered on 11 May 2010, 07:14 AM
Hello Danny,

You need to set a binding expression for the CommandArgument property of the link button as follows:
CommandArgument='<%# Eval("YourDataField") %>'

Hope it helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Danny
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Danny
Top achievements
Rank 1
Share this question
or