开发者

How to access telerik ajax radgrid values in the controller?

I am new to using Telerik and asp.net. The application I'm trying to build uses telerik ajax controls in asp.net MVC2 application. I have used a Telerik RadGrid of Ajax in my view of the mvc2 application as follows:

    <form runat="server" id="form1" method="post">   

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">   

</telerik:RadScriptManager>  

<h2>Index</h2>  


<telerik:RadGrid ID="RadGrid1" runat="server"    

DataSourceID="SqlDataSource1" AllowPaging="True" GridLines="None"    

AllowMultiRowSelection="True" Skin="Web20" AutoGenerateColumns="False">   

<MasterTableView DataSourceID="SqlDataSource1" AllowFilteringByColumn="True"    

DataKeyNames="Val1">   


<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>  

<RowIndicatorColumn>  

<HeaderStyle Width="20px"></HeaderStyle>  

</RowIndicatorColumn>  

<ExpandCollapseColumn>  

<HeaderStyle Width="20px"></HeaderStyle>  

</ExpandCollapseColumn>  

<Columns>  

<telerik:GridBoundColumn DataField="Val1" HeaderText="Val1"    

SortExpression="Val1" UniqueName="Val1">   

</telerik:GridBoundColumn>开发者_运维知识库;  

<telerik:GridBoundColumn DataField="Val2" HeaderText="Val2" ReadOnly="True"    

SortExpression="Val2" UniqueName="Val2">   

</telerik:GridBoundColumn>  


</Columns>  

</MasterTableView>  

<ClientSettings ActiveRowIndex="0" AllowKeyboardNavigation="True" >  

<Selecting AllowRowSelect="True" />  

</ClientSettings>  

</telerik:RadGrid>  




<asp:SqlDataSource ID="SqlDataSource1" runat="server"    

ConnectionString="<%$ ConnectionStrings:SomeConnectionString %>"    

SelectCommand="SELECT * FROM [someTable]"></asp:SqlDataSource>  


<input type="submit" value="Submit"/>   





</form> 

I want to access the selected values from the RadGrid in my controller(atleast the key value). How can I do that?

Thanks in advance, Hilda


My guess is that you can do that using the SelectedItems collection of the grid, then fetch the key values from the selected rows from there as done here.

Still if you rely on the pure MVC concept, think about switching the telerik ajax grid with their mvc grid extension which is pure mvc component.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜