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

insert update delete rdgrid

25 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajeswari
Top achievements
Rank 1
Rajeswari asked on 27 Apr 2014, 02:04 AM
I have a requirement insert rows to radgid .The radgrid will have 3 Radcomboboxes , one text boxes If one of the radcomboboxes selected value contains "nearest" or "top" I have ton add rad numeric text boxes to one colun of the of the grid. All the radcombo will have static texts and values in aspx page. The combo boxes are not tied with any datasources. I am very new to editable Radgrid .How can I do this.Please heilp me.
Thanks
RR

25 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Apr 2014, 06:02 AM
Hi Rajeswari,

I guess you have three RadComboBox in the edit mode of the RadGrid, and on one RadComboBox selection change you want to change the control of another RadComboBox. Please have a look at the following code snippet.

ASPX:
<Columns>  
    <telerik:GridTemplateColumn HeaderText="ComboBox1" Display="false">
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="RadComboBox1" EmptyMessage="Select" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                <Items>
                    <telerik:RadComboBoxItem Text="Nearest" Value="1" />
                    <telerik:RadComboBoxItem Text="Top" Value="2" />
                    <telerik:RadComboBoxItem Text="Others" Value="3" />
                </Items>
            </telerik:RadComboBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="ComboBox2" Display="false">
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="RadComboBox2" EmptyMessage="Select">
                <Items>
                    <telerik:RadComboBoxItem Text="1" Value="1" />
                    <telerik:RadComboBoxItem Text="2" Value="2" />
                    <telerik:RadComboBoxItem Text="3" Value="3" />
                    <telerik:RadComboBoxItem Text="4" Value="4" />
                </Items>
            </telerik:RadComboBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="ComboBox3" Display="false">
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="RadComboBox3" EmptyMessage="Select">
                <Items>
                    <telerik:RadComboBoxItem Text="Yes" Value="1" />
                    <telerik:RadComboBoxItem Text="No" Value="0" />
                </Items>
            </telerik:RadComboBox>         
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
</Columns>

C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    RadComboBox combo1 = (RadComboBox)sender;
    GridEditableItem editItem = (GridEditableItem)combo1.NamingContainer;
    string selectedText = combo1.SelectedItem.Text;
    RadComboBox combo2 = (RadComboBox)editItem.FindControl("RadComboBox2");
    if (selectedText == "Nearest")
    {
        combo2.Visible = false;
        TextBox textbox = new TextBox();
        textbox.ID = "TextBox1";
        combo2.Parent.Controls.Add(textbox);       
    }
    else if (selectedText == "Top")
    {
        combo2.Visible = false;
        RadNumericTextBox radnumerictextbox = new RadNumericTextBox();
        radnumerictextbox.ID = "RadNumericTextBox";
        combo2.Parent.Controls.Add(radnumerictextbox);
    }
    else
    {
        combo2.Visible = true;
    }
}

Please elaborate on your requirement if this doesn't help, and provide your code snippet as well.
Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 28 Apr 2014, 06:29 PM
 Hi Princy
Thanks for your reply. I am showing the grid when one of the option button is selected on the page. I want to show the grid in editmode with the comboboxes when the grid first time loaded. The grid is will not be associated with  any data table. I am binding with empty datatable for the grid to appear. I am able to display the combo boxes when the grid loaded first time  I am doing it in grid prerender event lke this. I  also populate the 3 comboboxes in the code behind grids onitemdatabound event. When the grid loaded for the first time , I want  to show only insert text in Gridedicommandbutton . I dont want to show Update text. I am not able to do this. How do I poipulate the grid with Radcomboiboxes selected values. Also if one of the combos selected value is "nearest" Grids column should have numeric text box .. If the user select insert or update button I will have to add grids column values to the where clause of the sql to populate total hits column of the grid.I am attaching the aspx and code
<telerik:RadGrid ID="gridkeyfin" AutoGenerateColumns="false" runat="server"

Skin="Default" Width="100%" Height="100px" AllowAutomaticInserts="true" OnItemDataBound="Onitemdataboundhandler" AllowAutomaticUpdates="true" AllowAutomaticDeletes="false" AutoGenerateEditButton="true">
<MasterTableView TableLayout="Fixed" BorderWidth="0" EditMode="InPlace"
runat="server"
ShowHeadersWhenNoRecords="true" AutoGenerateColumns="false" >
<Columns>
<telerik:GridTemplateColumn UniqueName="coljoin" HeaderText="Join">
<HeaderStyle Width="10%" Font-Bold="true" BackColor="#d6d3ce"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lJoin" Text="" Style="text-align: center;" runat="server" Width="10%" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox Height="100px" Width="60px" ID="cmbjoin" Autopostback="true" runat="server">

</telerik:RadComboBox></EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Colfield" HeaderText="Field">
<HeaderStyle Width="30%" Font-Bold="true" BackColor="#d6d3ce"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lField" Text="" Style="text-align: center;" runat="server" Width="30%" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox Height="80px" Width="180px" Autopostback="true" ID="cmbField" runat="server">

</telerik:RadComboBox></EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Coloperator" HeaderText="Operator">
<HeaderStyle Width="15%" Font-Bold="true" BackColor="#d6d3ce"></HeaderStyle>

<EditItemTemplate>
<telerik:RadComboBox Height="100px" Width="80px" AutoPostBack="true" ID="cmboperator"
runat="server">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn UniqueName="Colvalue" HeaderText="$ Value Selected">
<HeaderStyle Width="20%" Font-Bold="true" BackColor="#d6d3ce"></HeaderStyle>
<ItemTemplate>
<telerik:RadTextBox ID="txtvalue" runat="Server" AutoPostBack="true">
</telerik:RadTextBox></ItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn UniqueName="ColHits" HeaderText="Total Hits" >
<HeaderStyle Width="10%" Font-Bold="true" BackColor="#d6d3ce"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lhits" Text="" Style="text-align: center;" runat="server" Width="15%" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridRowIndicatorColumn runat="server"></telerik:GridRowIndicatorColumn>
<telerik:GridEditCommandColumn ItemStyle-Width="200px" EditText="ADD" HeaderStyle-Font-Bold="true" UniqueName="EditCommandColumn"
HeaderText="ADD" HeaderStyle-BackColor="#d6d3ce" UpdateText="Insert" HeaderStyle-Height="15px" CancelText="Cancel" ButtonType="linkbutton" HeaderButtonType="TextButton"
HeaderStyle-Width="10px">
</telerik:GridEditCommandColumn>

</Columns>


</MasterTableView>
</telerik:RadGrid>
Private Sub gridkeyfin_PreRender(sender As Object, e As System.EventArgs) Handles gridkeyfin.PreRender
For Each Item As GridItem In gridkeyfin.MasterTableView.Items
If TypeOf Item Is GridEditableItem Then
Dim editableitem As GridEditableItem = CType(Item, GridDataItem)
editableitem.Edit = True
End If
Next
gridkeyfin.Rebind()
End Sub

 





 . 
0
Princy
Top achievements
Rank 2
answered on 29 Apr 2014, 06:29 AM
Hi Rajeswari,

Please take a look at the below code snippet. I guess you want to hide the EditColumn first and make the grid in InsertMode. Please set the CommandItemDisplay property of the MasterTableView and try the following.

ASPX:
<MasterTableView CommandItemDisplay="Top">

VB:
Shared isSelected As Boolean = False
Protected Sub gridkeyfin_ItemDataBound(sender As Object, e As GridItemEventArgs)
    ' Hide the editcolumn
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim editButton As LinkButton = DirectCast(item("EditCommandColumn").Controls(0), LinkButton)
        editButton.Visible = False
    End If
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
        Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim comboBoxcmbjoin As RadComboBox = DirectCast(editItem.FindControl("cmbjoin"), RadComboBox)
        'Bind the RadComboBox here
            'set the selectedtext here
        comboBoxcmbjoin.SelectedValue = "SomeValue"
    End If
End Sub
Protected Sub gridkeyfin_PreRender(sender As Object, e As EventArgs)
    'Show the grid in insert mode
    If Not IsPostBack Then
        gridkeyfin.MasterTableView.IsItemInserted = True
        gridkeyfin.Rebind()
    End If
End Sub
Protected Sub cmbjoin_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
    isSelected = True
    Dim cmbjoin As RadComboBox = DirectCast(sender, RadComboBox)
    Dim editItem As GridEditableItem = DirectCast(cmbjoin.NamingContainer, GridEditableItem)
    Dim selectedText As String = cmbjoin.SelectedItem.Text
    Dim cmbField As RadComboBox = DirectCast(editItem.FindControl("cmbField"), RadComboBox)
    'Access other fields similarly
    If selectedText = "Nearest" Then
        isSelected = True
        cmbField.Visible = False
        'set the RadNumericTextBox for combobox
        Dim radnumerictextbox As New RadNumericTextBox()
        radnumerictextbox.ID = "RadNumericTextBox"
            'similarly add for all the controls you need
        cmbField.Parent.Controls.Add(radnumerictextbox)
    Else
        cmbField.Visible = True
    End If
End Sub
 
Protected Sub gridkeyfin_UpdateCommand(sender As Object, e As GridCommandEventArgs)
    'Access the edit form for manual operation
    Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
    Dim cmbField As RadComboBox = DirectCast(editItem.FindControl("cmbjoin"), RadComboBox)
    Dim num As RadNumericTextBox = DirectCast(editItem.FindControl("RadNumericTextBox"), RadNumericTextBox)
End Sub
Protected Sub gridkeyfin_ItemCreated(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode AndAlso isSelected Then
        Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim cmbjoin As RadComboBox = DirectCast(editItem.FindControl("cmbjoin"), RadComboBox)
        Dim cmbField As RadComboBox = DirectCast(editItem.FindControl("cmbField"), RadComboBox)
        If cmbjoin.SelectedItem.Text = "Nearest" Then
            cmbField.Visible = False
            Dim radnumerictextbox As New RadNumericTextBox()
            radnumerictextbox.ID = "RadNumericTextBox"
            cmbField.Parent.Controls.Add(radnumerictextbox)
        End If
    End If
End Sub

Please not that you cannot combine manual and automatic CRUD operations.Please take a look at this demo to know about the operations:
Grid - Automatic Operations and Grid - Manual CRUD Operations

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 30 Apr 2014, 08:47 PM
Hi Princy ,Thanks for your update. After your suggestions I updated the code . I made the grid to insert mode pre render and also made the edit form button visible to false in item databound. But now when the grid is loaded I am seeing all the comboboxes in the Gridtemplatecolumn( in edititemtemplate ). I am also seeing the Cancel button. My requirement is to have Add or Insert button when the grid loaded first with the combos , So user can select values and click on insert , I should populate grid rows with the selected values . The grid should populate with the values selected from the Gridtemplate column edititemplate only. I have to update the itemtemplate with the selected values. The Grids rows values should have to be a search citeria . I want to make sure , if i am using the right column types for the grid. If click on cancel or change the values in combobox , the grid disappears. Do i have to add selectedindexchanged function for each combo in the grid.
0
Princy
Top achievements
Rank 2
answered on 02 May 2014, 05:37 AM
Hi Rajeswari,

I guess initially you want to display a empty grid with Insert form open. The values inserted should be then shown in the grid rows along with edit and delete columns. Make sure that you bind the Grid using the NeedDataSource event so that it retains on postbacks. Please take a look at the sample code snippet given below. Let me know if any concern.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true" OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCreated="RadGrid1_ItemCreated" OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound">
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id">
        <Columns>
            <telerik:GridBoundColumn UniqueName="Id" DataField="Id" HeaderText="Id">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="Name" HeaderText="Name" DataField="Name">
                <ItemTemplate>
                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox ID="cmbName" AutoPostBack="true" AppendDataBoundItems="true" runat="server" OnSelectedIndexChanged="cmbName_SelectedIndexChanged">
                        <Items>
                            <telerik:RadComboBoxItem Text="Select" Value="" />
                            <telerik:RadComboBoxItem Text="Nearest" Value="1" />
                            <telerik:RadComboBoxItem Text="Top" Value="2" />
                            <telerik:RadComboBoxItem Text="Others" Value="3" />
                        </Items>
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="Country" HeaderText="Country" DataField="Country">
                <ItemTemplate>
                    <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Country") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox ID="cmbCountry" runat="server" AllowCustomText="true" AppendDataBoundItems="true"
                        EmptyMessage="Select">
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="ExamID" HeaderText="ExamID" DataField="ExamID">
                <ItemTemplate>
                    <asp:Label ID="lblExamID" runat="server" Text='<%# Eval("ExamID") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox ID="cmbExamID" runat="server" AllowCustomText="true" AppendDataBoundItems="true">
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT distinct [Name] FROM [Test]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT distinct [Country] FROM [Test]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT distinct [ExamID] FROM [Test]"></asp:SqlDataSource>

C#:
public static DataTable dtTable;
static bool isSelected = false;
SqlConnection SqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
public SqlDataAdapter SqlDataAdapter = new SqlDataAdapter();
public SqlCommand SqlCommand = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadGrid1.DataSource = new int[] { };
    }
}
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    dtTable = new DataTable();
    SqlConnection.Open();
    try
    {
        //Select Query to populate the RadGrid with data from table Employees.   
        string selectQuery = "SELECT * FROM Test";
        SqlDataAdapter.SelectCommand = new SqlCommand(selectQuery, SqlConnection);
        SqlDataAdapter.Fill(dtTable);
        RadGrid1.DataSource = dtTable;
    }
    finally
    {
        SqlConnection.Close();
    }
}
protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    int Id;
    string Name, Country, ExamID, insertQuery;
    GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
    Id = Convert.ToInt16((insertedItem["Id"].Controls[0] as TextBox).Text);
    RadComboBox cmbName = (RadComboBox)insertedItem.FindControl("cmbName");
    Name = cmbName.SelectedItem.Text;
    RadComboBox cmbCountry = (RadComboBox)insertedItem.FindControl("cmbCountry");
    Country = cmbCountry.Text;
    if (isSelected)
    {
        RadNumericTextBox numtxtExamID = (RadNumericTextBox)insertedItem.FindControl("radnumtxtExamID");
        ExamID = numtxtExamID.Text;
    }
    else
    {
        RadComboBox cmbExamID = (RadComboBox)insertedItem.FindControl("cmbExamID");
        ExamID = cmbExamID.Text;
    }
    try
    {
        //Open the SqlConnection   
        SqlConnection.Open();
        //Update Query to insert into  the database    
        insertQuery = "INSERT into Test(Id,Name,Country,ExamID) values('" + Id + "','" + Name + "','" + Country + "','" + ExamID + "')";
        SqlCommand.CommandText = insertQuery;
        SqlCommand.Connection = SqlConnection;
        SqlCommand.ExecuteNonQuery();
        //Close the SqlConnection   
        SqlConnection.Close();
    }
    catch (Exception ex)
    {
        RadGrid1.Controls.Add(new LiteralControl("Unable to insert Data. Reason: " + ex.Message));
        e.Canceled = true;
    }
}
protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    //Code to update
    //similar to Insert
}
protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    string Id, deleteQuery;
    GridDataItem dataItem = (GridDataItem)e.Item;
    Id = dataItem.GetDataKeyValue("Id").ToString();
    try
    {
        //Open the SqlConnection   
        SqlConnection.Open();
        //Update Query to insert into  the database    
        deleteQuery = "DELETE FROM Test WHERE Id='" + Id + "'";
        SqlCommand.CommandText = deleteQuery;
        SqlCommand.Connection = SqlConnection;
        SqlCommand.ExecuteNonQuery();
        //Close the SqlConnection   
        SqlConnection.Close();
    }
    catch (Exception ex)
    {
        RadGrid1.Controls.Add(new LiteralControl("Unable to Delete Data. Reason: " + ex.Message));
        e.Canceled = true;
    }
 
}
protected void cmbName_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox cmbName = (RadComboBox)sender;
    GridEditableItem editItem = (GridEditableItem)cmbName.NamingContainer;
    string selectedText = cmbName.SelectedItem.Text;
    RadComboBox cmbExamID = (RadComboBox)editItem.FindControl("cmbExamID");
    if (selectedText == "Nearest")
    {
        isSelected = true;
        cmbExamID.Visible = false;
        //set the RadNumericTextBox for combobox
        RadNumericTextBox radnumerictextbox = new RadNumericTextBox();
        radnumerictextbox.ID = "radnumtxtExamID";
        cmbExamID.Parent.Controls.Add(radnumerictextbox);
    }
    else
    {
        cmbExamID.Visible = true;
    }
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode && isSelected)
    {
        GridEditableItem editItem = (GridEditableItem)e.Item;
        RadComboBox cmbName = (RadComboBox)editItem.FindControl("cmbName");
        RadComboBox cmbExamID = (RadComboBox)editItem.FindControl("cmbExamID");
        if (cmbName.SelectedItem.Text == "Nearest")
        {
            cmbExamID.Visible = false;
            RadNumericTextBox radnumerictextbox = new RadNumericTextBox();
            radnumerictextbox.ID = "radnumtxtExamID";
            cmbExamID.Parent.Controls.Add(radnumerictextbox);
        }
 
    }
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadGrid1.MasterTableView.IsItemInserted = true;
        RadGrid1.Rebind();
    }
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item.IsInEditMode && e.Item is GridEditableItem && !e.Item.OwnerTableView.IsItemInserted)
    {
        GridEditableItem editItem = (GridEditableItem)e.Item;
        RadComboBox cmbName = (RadComboBox)editItem.FindControl("cmbName");
        RadComboBox cmbExamID = (RadComboBox)editItem.FindControl("cmbExamID");
        RadComboBox cmbCountry = (RadComboBox)editItem.FindControl("cmbCountry");
        cmbName.DataSourceID = "SqlDataSource1";
        cmbName.DataTextField = "Name";
        cmbName.DataValueField = "Name";
        cmbCountry.DataSourceID = "SqlDataSource2";
        cmbCountry.DataValueField = "Country";
        cmbCountry.DataTextField = "Country";
        cmbExamID.DataSourceID = "SqlDataSource3";
        cmbExamID.DataTextField = "ExamID";
        cmbExamID.DataValueField = "ExamID";
        // To set the selected value in edit mode
        cmbName.SelectedValue = DataBinder.Eval(editItem.DataItem, "Name").ToString();
        cmbCountry.SelectedValue = DataBinder.Eval(editItem.DataItem, "Country").ToString();
        cmbExamID.SelectedValue = DataBinder.Eval(editItem.DataItem, "ExamID").ToString();
    }
}

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 04 May 2014, 08:41 PM
Hi Princy , Thank you very much . I am going to use in memory data table for the grid. The grid will not have any data rows . When its load first time. User will be selecting items from Editemplate combo and inserting to the grid When i set AutoGenerateeditcolumn = true, it displayed the editemplate fields when i click on te add a new record button, But the editables column were vertical . I want the column to be horizontal below the header is it possible ,how can i do that.

Thanks,
Rajee
0
Princy
Top achievements
Rank 2
answered on 05 May 2014, 06:14 AM
Hi Rajeswari,

If you do not want the Edit to be displayed in the Rows. You can set it in the CommandItemTemplate as shown in this demo - Grid - Command Item.

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 05 May 2014, 05:30 PM
Hi Princy
Thanks. I think I made you confused , I attached a picture , when the grid loads , i want to show  the grid as in attachment  , I made it editmode inplace. I dont want to  show the editform . I dont have any datatable with rows. Once the user change the selection in the radcomboboboxes in in edititemtemplate  and click on insert link , I have to add a row to the datatable and displayed it in the grid cells. When i set it in edit mode , i also see another edit button below insert/cancel , I dont know why that is showing . On Prerender, i added  code like this as you suggested  gridkeyfin.MasterTableView.IsItemInserted = True gridkeyfin.Rebind(). I have selected index changed event for all the combos , When i changed the values , i want retain the values for all the combos anc click on insert i should be adding the row to the in memory table and populate the grid. I hope you understood my specifications. If you look at the attachment , you will  understand. ,
Thanks
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 06 May 2014, 04:23 AM
Hi Rajeswari,

Unfortunately I'm not able to replicate the issue. Please provide your full code snippet. Its hard to identify the issue without your code.

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 11 May 2014, 02:13 PM
 Hi Princy,
I have this grid inside the asp panel which is not visible in the page load. I am making the asp panel visible in the option button changed event in the page. I am also binding the grid to an empty datatable in the same event. I am making the grid items to insert mode in the prerender. When i  change the value of the Radcombobox inside the grid, the grid disappears. I have the autopostback property of the combo set to true and also have selected event changed event. In that event I am setting the selected value to the viewstate . Event when i call rebind in the selected event changed event nothing happens, the grid disapperars. I have the grid in the ajaxsettings. I also have the asp panel inside the updated controls in ajaxsettings onf the optiob button . What am i mssing here.Is that because the  asp panel is not visible in page load? Do i have to do something special for invisible controls in the page load. Following is my aspx code ajax setting I have two grid in the page. Other grid is outside the panel
<telerik:RadAjaxManager ID="RadAjaxManager1" runat ="server" >
<AjaxSettings >
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gridpeer" />
<telerik:AjaxUpdatedControl ControlID="gridkeyfin" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="gridkeyfin">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gridkeyfin" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="rbviewSelection">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="pnlstateselection" />
<telerik:AjaxUpdatedControl ControlID="pnllineselection" />
<telerik:AjaxUpdatedControl ControlID="pnlfinselection" />
<telerik:AjaxUpdatedControl ControlID="rbviewSelection" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<asp:Panel ID="pnlfinselection" runat="server">
<div style="vertical-align: bottom; margin-top: 105px; height: 300px; width: 97%;
margin-left: 10px;">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="keyfinlbl">
<asp:Label ID="lblkey" runat="server" Text="Use Key Financial Fields (P/C):"></asp:Label>
</td>
</tr>
<tr>
<td>
<telerik:RadGrid ID="gridkeyfin" AutoGenerateColumns="false" runat="server" AutoGenerateEditColumn="false"
Skin="Default" Width="100%" Height="100px" OnItemDataBound="Onitemdataboundhandler"
OnUpdateCommand="gridkeyfin_UpdateCommand" AllowAutomaticInserts="true" OnItemCreated="gridkeyfin_ItemCreated"
OnNeedDataSource="gidkeyfin_NeedDataSource">
<MasterTableView TableLayout="Fixed" BorderWidth="0" runat="server" CommandItemDisplay="none"
EnableViewState="true" EditMode="InPlace" ShowHeadersWhenNoRecords="false" AutoGenerateColumns="false">
<Columns>
<telerik:GridTemplateColumn UniqueName="coljoin" HeaderText="Join">
<HeaderStyle Width="15%" Font-Bold="true"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lJoin" Text='<%#Eval("displayJoin")%>' Style="text-align: center;"
runat="server" Width="10%" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox Height="100px" Width="65px" AutoPostBack="false" ID="cmbjoin"
runat="server" >
<Items>
<telerik:RadComboBoxItem runat="server" Value="Select" Text="Select" />
<telerik:RadComboBoxItem runat="server" Value="And" Text="And" />
<telerik:RadComboBoxItem runat="server" Value="Or" Text="Or" />
<telerik:RadComboBoxItem runat="server" Value="Minus" Text="Minus" />
</Items>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Colfield" HeaderText="Field">
<HeaderStyle Width="28%" Font-Bold="true"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lField" Text='<%#Eval("displayfield")%>' Style="text-align: center;"
runat="server" Width="30%" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox Height="80px" Width="160px" AutoPostBack="false" ID="cmbField"
runat="server" OnSelectedIndexChanged="CmbField_selectedIndexChanged">
<Items>
<telerik:RadComboBoxItem runat="server" Value="Select" Text="Select" />
<telerik:RadComboBoxItem runat="server" Value="DPW" Text="Direct Preminu Written" />
<telerik:RadComboBoxItem runat="server" Value="NPW" Text="Net Premium Written" />
<telerik:RadComboBoxItem runat="server" Value="Assets" Text="Total Assets" />
<telerik:RadComboBoxItem runat="server" Value="PHS" Text="PHS" />
</Items>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Coloperator" HeaderText="Operator">
<HeaderStyle Width="15%" Font-Bold="true"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lbloperator" Text='<%#Eval("displayoperator")%>' Style="text-align: center;"
runat="server" Width="30%" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox Height="100px" Width="80px" AutoPostBack="true" ID="cmboperator"
runat="server" OnSelectedIndexChanged="cmboperator_selectedindexchanged" >
<Items>
<telerik:RadComboBoxItem runat="server" Value="Select" Text="Select" />
<telerik:RadComboBoxItem runat="server" Value=">" Text=">" />
<telerik:RadComboBoxItem runat="server" Value="<" Text="<" />
<telerik:RadComboBoxItem runat="server" Value="=" Text="=" />
<telerik:RadComboBoxItem runat="server" Value="Between" Text="Between" />
<telerik:RadComboBoxItem runat="server" Value="Nearest" Text="Nearest" />
<telerik:RadComboBoxItem runat="server" Value="Top" Text="Top" />
</Items>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Colvalue" HeaderText="$ Value Selected">
<HeaderStyle Width="25%" Font-Bold="true"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lblvalue" Text='<%#Eval("displaysearchvalue")%>' runat="server" Style="text-align: center;"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtvalue" Width="110px" runat="Server" AutoPostBack="true">
</telerik:RadTextBox></EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="ColHits" HeaderText="Total Hits">
<HeaderStyle Width="8%" Font-Bold="true"></HeaderStyle>
<ItemTemplate>
<asp:Label ID="lhits" Text='<%#Eval("displayHits")%>' Style="text-align: center;"
runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"
ItemStyle-Width="180px" ItemStyle-Font-Bold="true" InsertText="ADD" HeaderStyle-Font-Bold="true"
UniqueName="EditCommandColumn" HeaderText="ADD" HeaderStyle-Height="15px" ButtonType="linkbutton"
HeaderButtonType="TextButton" HeaderStyle-Width="10px">
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td width="100%">
<telerik:RadButton ID="btnclearcriteria" runat="server" Text="Clear Criteria" Skin="MyForest"
EnableEmbeddedSkins="false">
</telerik:RadButton>
&nbsp;
<telerik:RadButton ID="btnremovecriteria" runat="server" Text="Remove Criteria" Skin="MyForest"
EnableEmbeddedSkins="false">
</telerik:RadButton>
</td>
</tr>
</table>
</div>
</asp:Panel>
Following is my vb code for grid
Private Sub gridkeyfin_PreRender(sender As Object, e As System.EventArgs) Handles gridkeyfin.PreRender
      
        For Each Item As GridItem In gridkeyfin.MasterTableView.Items
            If TypeOf Item Is GridEditableItem Then
                Dim editableitem As GridEditableItem = CType(Item, GridDataItem)
                editableitem.Edit = True
            End If
        Next
      
        btnclearcriteria.Enabled = True
        btnremovecriteria.Enabled = True
        gridkeyfin.Rebind()
    End Sub
Protected Sub gidkeyfin_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
Dim dskey As New DataSet
Dim dtkey As DataTable
If Not ViewState("dsCriteria") Is Nothing Then
dskey = ViewState("dsCriteria")
Dim dr As DataRow
' TryCast(sender, RadGrid).DataSource = dskey.Tables(0)
gridkeyfin.DataSource = dskey.Tables(0)
End If
End Sub
Protected Sub Onitemdataboundhandler(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
               
  
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then            Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)            'Dim comboBoxcmbjoin As RadComboBox = DirectCast(editItem.FindControl("cmbjoin"), RadComboBox)
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)            Dim editButton As LinkButton = DirectCast(item("EditCommandColumn").Controls(0), LinkButton)
            Dim Cancelbutton As LinkButton = DirectCast(item("EditCommandColumn").Controls(2), LinkButton)
            Cancelbutton.Visible = False
            If editButton.Text = "Update" Then
                editButton.Text = "ADD"
            End If
          
        End If        If e.Item.IsInEditMode And TypeOf e.Item Is GridEditableItem And Not e.Item.OwnerTableView.IsItemInserted Then
            Dim edititem As GridEditableItem = e.Item
            Dim cmbjoin As RadComboBox = DirectCast(edititem.FindControl("cmbjoin"), RadComboBox)
            Dim cmbField As RadComboBox = DirectCast(edititem.FindControl("cmbField"), RadComboBox)
            Dim cmboperator As RadComboBox = DirectCast(edititem.FindControl("cmboperator"), RadComboBox)
            cmbjoin.SelectedValue = ViewState("Join")
            cmbField.SelectedValue = ViewState("Field")
            cmboperator.SelectedValue = ViewState("Operator")
        End If
    End Sub
Protected Sub cmboperator_selectedindexchanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
Dim sOperator As String = String.Empty

Dim cmb As RadComboBox = DirectCast(sender, RadComboBox)
If cmb.SelectedValue <> "Select" Then
sOperator = cmb.SelectedValue
ViewState.Add("Operator", sOperator)
End If
End Sub
Thanks,
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 13 May 2014, 04:04 AM
Hi Rajeswari,

Please try the following sample code snippet. I have modified your code and the grid is persisting with the ComboBox selected values.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="pnlGrid" />
                <telerik:AjaxUpdatedControl ControlID="btnShowGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="btnShowGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="pnlGrid" />
                <telerik:AjaxUpdatedControl ControlID="btnShowGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<asp:Button ID="btnShowGrid" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Panel ID="pnlGrid" runat="server" Visible="false">
    <telerik:RadGrid ID="gridSample" runat="server" AllowPaging="true">
        <MasterTableView CommandItemDisplay="Top" EditMode="InPlace">
            <Columns>
                <telerik:GridTemplateColumn UniqueName="ID" HeaderText="ID">
                    <ItemTemplate>
                        <asp:Label ID="lblID" Text='<%#Eval("ID")%>' runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox AutoPostBack="true" ID="cmbSelect" runat="server" OnSelectedIndexChanged="cmbSelect_selectedindexchanged">
                        <Items>
                         <telerik:RadComboBoxItem runat="server" Value="Select" Text="Select" />
                         <telerik:RadComboBoxItem runat="server" Value=">" Text=">" />
                         <telerik:RadComboBoxItem runat="server" Value="<" Text="<" />
                         <telerik:RadComboBoxItem runat="server" Value="=" Text="=" />                              
                        </Items>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn UniqueName="City" HeaderText="City">
                    <ItemTemplate>
                        <asp:Label ID="lblCity" Text='<%#Eval("City")%>' runat="server"></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadTextBox ID="txtvalue" runat="Server" ></telerik:RadTextBox>
                   </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="linkbutton" InsertText="Add">
                </telerik:GridEditCommandColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Panel>

VB:
Private isVisible As Boolean = False
Protected Sub gridSample_PreRender1(sender As Object, e As EventArgs)
    If isVisible Then
        gridSample.MasterTableView.IsItemInserted = True
        gridSample.Rebind()
    End If
End Sub
Protected Sub Onitemdataboundhandler(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataInsertItem AndAlso e.Item.OwnerTableView.IsItemInserted Then
        gridSample.MasterTableView.GetColumn("EditCommandColumn").Visible = True
        For Each dataItem As GridDataItem In gridSample.MasterTableView.Items
            DirectCast(dataItem("EditCommandColumn").Controls(0), LinkButton).Visible = False
        Next
    Else
        gridSample.MasterTableView.GetColumn("EditCommandColumn").Visible = False
    End If
 
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs)
    pnlGrid.Visible = True
    isVisible = True
End Sub

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 15 May 2014, 03:19 PM
Thanks Princy , That worked , I want to access the itemtemplate in Gridtemplate column in  itemdatabound event. How can i do that? Can i have two controls( one as label and other one as Radnumerictextbox) in itemtemplate in Gridtemplatecolumn . I want to make one visible and other one as invisible based on the condition of the Radcombobox selected value in the Edititemtemplate column.
Thanks,
Rajeswari Raman
0
Princy
Top achievements
Rank 2
answered on 16 May 2014, 04:17 AM
Hi Rajeswari,

I guess you have a GridTemplateColumn with Label and RadNumericTextBox in ItemTemplate, then Another TemplateColumn having a Label in ItemTemplate and RadComboBox in EditItemTemplate. According to the value of second column you want to hide and show the controls in first column. Please try the following code snippet:

ASPX:
<telerik:GridTemplateColumn UniqueName="ID" HeaderText="ID">
    <ItemTemplate>
        <asp:Label ID="lblID" Text='<%#Eval("ID")%>' runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadComboBox ID="cmbID" runat="server". .>         
        </telerik:RadComboBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>
 
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:Label ID="Label" runat="server" Text="Label"></asp:Label>
        <telerik:RadNumericTextBox ID="RadNumericTextBox" runat="server">
        </telerik:RadNumericTextBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem)
  {
    GridDataItem dataItem = (GridDataItem)e.Item;
    Label lblID = (Label)dataItem.FindControl("lblID");
    string ID =lblID.Text;
    Label lbl = (Label)dataItem.FindControl("Label");
    RadNumericTextBox rntxt = (RadNumericTextBox)dataItem.FindControl("RadNumericTextBox");
    if (ID == "Some Value")
    {
        lbl.Visible = false;
        rntxt.Visible = true;
    }
    else
    {
        rntxt.Visible = false;
        lbl.Visible = true;
    }
  }
}

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 16 May 2014, 02:51 PM
Hi Princy . Thanks . I have 3 Gridtemplatecolumn in the grid. all the 3 gridtemplate column had itemtemplate and edititemtempllate. I have to to show the label or radnumeric text box in the same itemtemplate based on the  ediiitemplate combobox selected value in the same gridtemplate column. when i  add the following code on itemdatabound I am getting finding nothing on lblid
GridDataItem dataItem = (GridDataItem)e.Item; Label lblID = (Label)dataItem.FindControl("lblID"); I added follwing code if it will recognise the lable in itemtemplate column .
Dim dataitem As GridDataItem = DirectCast(e.Item, GridDataItem)
   Dim cell As TableCell = dataitem("Coloperator") where "Coloperator" is the uniquename of gridtemplatecoolumn whe i do the following  cell.Controls(0) , the label is showing as Literalcontrol .  Radnumerictextbox as literal control . But combobox is showing as radcombobox. I would like to access the label and Radnumerictext box in itemtemplate , on itemdatabound.
Thanks,
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 17 May 2014, 05:51 AM
Hi Rajeswari,

I guess you are having issue accessing the controls of template column in edit or view mode. Please take a look at the following help documentation on Accessing Cells and Rows which will help you with your requirement.

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 21 May 2014, 08:56 PM
Hi Princy ,
When the grid is in edit command  if i change the value in the combox in the radgrid selected row  , the  Edittemplateitem  combox value is also changing. I am not showing the Editform separately. IIs the parto fhe grid and when the grid loads first  all the mastertableview are inserted. I have a indatabound handler where i am setting the values of the comboboxes. Once in Editmode i want the editable items to be read only . How can i do that
Thanks,
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 22 May 2014, 05:04 AM
Hi Rajeswari,

You can try the following code snippet to disable the rows in editmode.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{   
  if (e.Item is GridEditableItem && e.Item.IsInEditMode && !e.Item.OwnerTableView.IsItemInserted)
  {           
    GridEditableItem editItem = (GridEditableItem)e.Item;
    (editItem["ColumnUniqueName"].Controls[0] as TextBox).ReadOnly = true;
           //  or
    editItem["ColumnUniqueName"].Enabled = false;
  }
}

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 28 May 2014, 08:40 PM
Hi Princy,
I have gridbuttoncolumn with the button type as image button and command name as delete . I want to to show the button color in red. I added css class . Still I am not able to see the color . How can I do that.
Thanks
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 29 May 2014, 06:04 AM
Hi Rajeswari,

The styles of the Button varies according to the Skin property you set. I'm afraid changing the color is not possible. You can add your own image instead of the default image.

ASPX:
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ImageUrl="delete.jpg">
</telerik:GridButtonColumn>

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 29 May 2014, 08:58 PM
Thanks Princy. I have a lable in  the Grid Edititemtemplate of GridTemplateColumn . The label has hardcoded text. I want to make the label text  align to center I am trying to do it in css , but its not displaying in center. How can i do that.
Thanks,
Rajeswari
0
Princy
Top achievements
Rank 2
answered on 30 May 2014, 04:41 AM
Hi Rajeswari,

You can add the label to a div and style it, as shown below:

ASPX:
<telerik:GridTemplateColumn>
  <EditItemTemplate>
    <div style="margin-left: auto; margin-right: auto; text-align: center;">
        <asp:Label ID="Label" runat="server" Text="ABC"></asp:Label>
    </div>
  </EditItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 05 Jun 2014, 06:53 PM
Hi Princy
i am not he add new button in the grid. when the grid loads  i am binding the empty datatable and also has following code to show the editform items as part of the grid
gridkeyfin.MasterTableView.IsItemInserted = True . So far delete , insert , update are working fine. I have a clear button outside the grid , if the button is clickeded , i want to clear the rows inserted , i have the following code
gridkeyfin.MasterTableView.SortExpressions.Clear()
gridkeyfin.DataSource = New String("") gridkeyfin.DataBind() bu am getting following error in aspx where i have gridiemplate column itemtemplate with<asp:Label ID="lhits" Text='<%#Eval("displayHits")%>' Style="text-align: center;"
runat="server" />
DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'displayHits'. I saw many forums saying to  bind with default values to fix the error. If i do that when the grid loads I am getting a blank row in the grid with edit cancel buttons . How can i fix the error. I also have another question regarding the selected row index grid in update and dele command. Is there any column in the grid that gives the current selected row on update/delete. I need to add the rowindex to the data base to do some calculations when i ansert the /update/deltete data.
Thanks,
Rajeswari Raman
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2014, 06:07 AM
Hi Rajeswari,

I'm not clear about the issue you have mentioned first, please provide your full code snippet. For your second requirement you can use ItemCommand event and get the rowindex.

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = RadGrid.UpdateCommandName Then
        Dim edit As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim index As Integer = edit.ItemIndex
    ElseIf e.CommandName = "Delete" Then
        Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim index As Integer = dataItem.ItemIndex
    End If
End Sub

Thanks,
Princy
0
Rajeswari
Top achievements
Rank 1
answered on 28 Jul 2014, 08:54 PM
Hi , I have a radlistbox inside the asp panel . Some times (not always) The list box items over flows. I have the height  set for the panel and also for the Radlist box I attached the image.
Thanks,
Rajeswari Raman
0
Princy
Top achievements
Rank 2
answered on 30 Jul 2014, 11:28 AM
Hi Rajeswari,

Please try setting the following css.

ASPX:
<asp:Panel ID="panel1" runat="server"  Height="100px" CssClass="panelclass" >
 
<telerik:RadListBox runat="server">...........</telerik:RadListBox>
 
</asp:Panel>

CSS:
<style  type="text/css">
    .panelclass
    {
        overflow:auto;
    }
</style>

Thanks,
Princy.
Tags
Grid
Asked by
Rajeswari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rajeswari
Top achievements
Rank 1
Share this question
or