<script type="text/javascript"> function openWin() { radopen(null, "RadWindow1"); } </script>Private Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then Dim dataItem As Telerik.Web.UI.GridDataItem = DirectCast(e.Item, Telerik.Web.UI.GridDataItem) Dim btnImage As Button = DirectCast(dataItem("column2").Controls(0), Button) btnImage.Attributes.Add("OnClick", "openWin(); return false;") End IfEnd Sub|
Id |
Desc |
Stats |
Action |
|
0 |
asas |
T |
A |
|
11 |
Public |
T |
A |
| 12 | asdgf | T | A |
| 888 | ghjk; | T | A |
I would like to click on my grid client select column, hit the edit button, and retain the checked/selected state of the item after postback, but for some reason the SelectItems count of the grid is 0 after databinding.
<Rad:RadGrid ID="testgrid"OnNeedDataSource="testgrid_NeedDataSource"ClientSettings-Selecting-AllowRowSelect="true" runat="server"> <MasterTableView CommandItemDisplay="Top" EditMode="InPlace"> <CommandItemTemplate> <Asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" EnableViewState="true" CausesValidation="false" Visible="true" Text="Edit" /> </CommandItemTemplate> <Columns> <Rad:GridClientSelectColumn UniqueName="testselect"> </Rad:GridClientSelectColumn> </Columns> </MasterTableView></Rad:RadGrid> protected void testgrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { IList<string> items = new List<string>(); items.Add("test"); testgrid.DataSource = items; }Hello,
I have a 'record update' feature enabled grid (2012 Q1).
I am using <FormTemplate> for editing/updating the data on the grid.
In the FormTemplate, I have a RadioButtonList named 'rdGrade' which is bound to the 'SchoolGrade' field in my database. The code for this RadioButtonList is as shown below.
<asp:RadioButtonList ID="rdGrade" runat="server"SelectedValue='<%# Bind("SchoolGrade") %>' DataSource='<%# (new string[] { "4", "5", "6" }) %>' AppendDataBoundItems="True"RepeatDirection="Horizontal"></asp:RadioButtonList>
Editing the SchoolGrade field with this RadioButtonList was fine. No errors.
But when I try to Add a new record by clicking the "+ Add new record" button, I get an error. So I had to add some extra code to the code behind page to set the default selected value of this RadioButtonList and the code I added was:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { //Add new" button clicked e.Canceled = true; //Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); newValues["SchoolGrade"] = 5; //Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); } }The code above sets the default selected value of the radio button list as 5.
My question is how do I change the code line
newValues["SchoolGrade"] = 5;
in order to initially UNCHECK the RadioButtonList rdGrade when a user clicks the 'Add new record' button on the grid?
Thank you.