or
<telerik:RadGrid ID="RadGrid1" runat="server" MasterTableView-EditMode="InPlace" DataSourceID="ObjectDataSource1" OnInsertCommand="RadGrid1_InsertCommand" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" > <MasterTableView AllowAutomaticDeletes="False" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="lead_id,location_id,seq_id" DataSourceID="ObjectDataSource1"> <NoRecordsTemplate> No Record Exists</NoRecordsTemplate> <Columns> <telerik:GridBoundColumn DataField="lead_id" DataType="System.Int32" FilterControlAltText="Filter lead_id column" HeaderText="lead_id" ReadOnly="True" SortExpression="lead_id" UniqueName="lead_id" Visible="False"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="location_id" DataType="System.Int32" FilterControlAltText="Filter location_id column" HeaderText="location_id" ReadOnly="True" SortExpression="location_id" UniqueName="location_id" Visible="False"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="seq_id" DataType="System.Int32" FilterControlAltText="Filter seq_id column" HeaderText="seq_id" ReadOnly="False" SortExpression="seq_id" UniqueName="seq_id"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="current_provider" FilterControlAltText="Filter current_provider column" HeaderText="current_provider" SortExpression="current_provider" UniqueName="current_provider"> <ColumnValidationSettings> <ModelErrorMessage Text="" /> </ColumnValidationSettings> </telerik:GridBoundColumn> </Columns> </MasterTableView></telerik:RadGrid><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="SALTDetailProviderDALTableAdapters.salt_company_providerTableAdapter" UpdateMethod="Update" > <DeleteParameters> <asp:Parameter Name="Original_lead_id" Type="Int32" /> <asp:Parameter Name="Original_location_id" Type="Int32" /> <asp:Parameter Name="Original_seq_id" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="lead_id" Type="Int32" /> <asp:Parameter Name="location_id" Type="Int32" /> <asp:Parameter Name="seq_id" Type="Int32" /> <asp:Parameter Name="current_provider" Type="String" /> <asp:Parameter Name="contract_exp_dt" Type="DateTime" /> <asp:Parameter Name="data_type" Type="Int16" /> <asp:Parameter Name="ld_min" Type="Int32" /> <asp:Parameter Name="line_cnt" Type="Int32" /> <asp:Parameter Name="primary_yn" Type="String" /> </InsertParameters> <SelectParameters> <asp:ControlParameter ControlID="LeadIdLabel" Name="lead_id" PropertyName="Text" Type="Int32" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="current_provider" Type="String" /> <asp:Parameter Name="contract_exp_dt" Type="DateTime" /> <asp:Parameter Name="data_type" Type="Int16" /> <asp:Parameter Name="ld_min" Type="Int32" /> <asp:Parameter Name="line_cnt" Type="Int32" /> <asp:Parameter Name="primary_yn" Type="String" /> <asp:Parameter Name="Original_lead_id" Type="Int32" /> <asp:Parameter Name="Original_location_id" Type="Int32" /> <asp:Parameter Name="Original_seq_id" Type="Int32" /> </UpdateParameters></asp:ObjectDataSource>protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e){ // Get last item's int count = RadGrid1.Items.Count; GridDataItem item = RadGrid1.Items[count - 1] as GridDataItem; // Get last item's provider name string providerName = item["current_provider"].Text; // Add 1 to last item's seq id string strSeqid = item["seq_id"].Text; int seqid = int.Parse(item["seq_id"].Text) + 1; // item about to get inserted GridDataInsertItem insertedItem = (GridDataInsertItem)e.Item; // Get provider name of the item about to get inserted TextBox providerNameTextBox = insertedItem["current_provider"].Controls[0] as TextBox; string providerNameInserted = providerNameTextBox.Text; // Modify the seq id (insertedItem["seq_id"].Controls[0] as TextBox).Text = seqid.ToString().Trim();}




<telerik:RadGrid ID="RadGrid1" Height="100%" runat="server" EnableHeaderContextMenu="true"> <ClientSettings> <Scrolling AllowScroll="True"></Scrolling> </ClientSettings></telerik:RadGrid>001. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load002. If Not IsPostBack Then003. Session("st") = Nothing004. Session("IsGridToBEShowen_flag") = 0005. End If006. End Sub007. 008. 009. Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click010. Session("Report_ID") = 1011. ReplaceReport012. End Sub013. 014. 015. Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click016. Session("Report_ID") = 2017. ReplaceReport018. End Sub019. 020. Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click021. Session("Report_ID") = 3022. ReplaceReport023. End Sub024. 025. 026. 027.Private Sub ReplaceReport()028. 029. rep.ID = Session("Report_ID")030. 031. 032. Pre_Report()033. setGridProperties()034. 035. End_Set_Report()036. 037. End Sub038.''''''''''''''''''''''''''''''''''''''''''039. 040. Private Sub Pre_Report()041. RadGrid1.Enabled = True042. RadGrid1.Visible = True043. Session("st") = Nothing044. Session("isGridInit") = True045. 046. Session("st") = rep.Data 'get specific DataSet into Session047. End Sub048. 049. Private Sub End_Set_Report()050. 051. RadGrid1.DataSource = CType(Session("st"), DataSet).Tables(0)052. 053. RadGrid1.DataBind()054. RadGrid1.Rebind()055. Session("IsGridToBEShowen_flag") = 1056. 057. End Sub058. 059. ''''''''''''''''''''060. ''''''''''''''''''''''''''''''''''''''''''''061. Private Sub setGridProperties()062. 063. 'set grid columns properties064. If Session("RTL") Then065. RadGrid1.MasterTableView.Dir = GridTableTextDirection.RTL066. Else067. RadGrid1.MasterTableView.Dir = GridTableTextDirection.LTR068. End If069. 070. If RadGrid1.MasterTableView.DetailTables.Count > 0 Then071. RadGrid1.MasterTableView.DetailTables(0).DataSource = Nothing072. RadGrid1.MasterTableView.DetailTables(0).DataSource = New Object() {}073. RadGrid1.MasterTableView.DetailTables(0).Rebind()074. 075. RadGrid1.MasterTableView.DetailTables.Remove(0)076. End If077. 078. Dim Number_Of_Tables As Integer = CType(Session("st"), DataSet).Tables.Count079. 080. If Number_Of_Tables = 2 Then081. RadGrid1.DataSource = Nothing082. RadGrid1.Rebind()083. 'add details View084. Dim detailsView1 As GridTableView = New GridTableView()085. detailsView1.Name = "Details"086. detailsView1.DataKeyNames = New String() {"Internal_ID"}087. RadGrid1.MasterTableView.DetailTables.Add(detailsView1)088. RadGrid1.MasterTableView.DataKeyNames = New String() {"Internal_ID"}089. RadGrid1.Rebind()090. 091. End If092. 093. 094. RadGrid1.MasterTableView.TableLayout = GridTableLayout.Fixed095. RadGrid1.ClientSettings.Selecting.AllowRowSelect = True096. RadGrid1.AllowSorting = True097. RadGrid1.AllowPaging = True098. RadGrid1.AllowMultiRowSelection = True099. RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = True100. RadGrid1.ShowHeader = True101. RadGrid1.AllowFilteringByColumn = True102. RadGrid1.MasterTableView.AllowFilteringByColumn = True103. RadGrid1.ClientSettings.AllowDragToGroup = True104. RadGrid1.ShowGroupPanel = True105. RadGrid1.MasterTableView.HeaderStyle.Width = Unit.Pixel(200)106. 107. RadGrid1.ClientSettings.Selecting.UseClientSelectColumnOnly = True108. RadGrid1.ClientSettings.EnableRowHoverStyle = True109. End Sub110. 111. Private Sub FirstSortGrid(colum_name As String)112. Dim expression As GridSortExpression = New GridSortExpression()113. expression.FieldName = colum_name114. expression.SortOrder = GridSortOrder.Ascending115. RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression)116. Session("isGridInit") = False117. End Sub118. 119. Protected Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource120. 121. Dim fl As Integer = Session("IsGridToBEShowen_flag")122. If fl = 1 Then123. RadGrid1.DataSource = CType(Session("st"), DataSet).Tables(0)124. 125. End If126. 127. End Sub128. 129. 130. 131. Private Sub RadGrid1_DetailTableDataBind(sender As Object, e As GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind132. Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)133. Select Case e.DetailTableView.Name134. Case "Details"135. Dim ConnectID As String = dataItem.GetDataKeyValue("Internal_ID").ToString()136. CType(Session("st"), DataSet).Tables(1).DefaultView.RowFilter = ""137. CType(Session("st"), DataSet).Tables(1).DefaultView.RowFilter = "Internal_ID = " & ConnectID138. e.DetailTableView.DataSource = CType(Session("st"), DataSet).Tables(1).DefaultView139. End Select140. End Sub