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

"Edit" and "Add" only 3 columns of RadGrid among 4 columns. and Bind RadGrid Dropdown with 2 DB table column together.

0 Answers 10 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Priyanka
Top achievements
Rank 1
Priyanka asked on 26 Jun 2015, 04:30 AM

I have a Stored Procedure in SQL Database as below:

ALTER PROCEDURE [General].[usp_tbl_AccountCode_Query_Search]
        @CompanyCode nvarchar (255) = Null,
        @AccountCode nvarchar(50) = Null,
        @Description nvarchar(1000) = Null
AS
BEGIN
    SET NOCOUNT ON;
     
    If (LTRIM(@CompanyCode) = '')
        Set @CompanyCode = Null
     
    If (LTRIM(@AccountCode) = '')
        Set @AccountCode = Null
         
    If (LTRIM(@Description) = '')
        Set @Description = Null
         
DECLARE @GroupId as nvarchar(50)=null
 
     
    Select @GroupId = GroupID  FROM [General].[tbl_Buyer] where code = @CompanyCode
 
    IF (@GroupId='8000')
    BEGIN
    Select Distinct
        AccountCodeID,
        CompanyCode,
        AccountCode,
        AccountDescription
    From General.tbl_AccountCode (NOLOCK)
    Where IsNull(AccountCode, '') Like '%' + Coalesce(@AccountCode, AccountCode, '') + '%'
        And IsNull(AccountDescription, '') Like '%' + '[' + Coalesce(@Description, AccountDescription, '') + ']' + + '%'
        And IsNull(AccountDescription, '') Like '%' + Coalesce(@Description, AccountDescription, '') + '%'
        --And CompanyCode in (Select Code FROM [Sunway_AP].[General].[tbl_Buyer] where GroupID = '8000')
        And CompanyCode = '8000'
    Order By AccountCode
    END
    ELSE IF (@GroupId='9000')
    BEGIN
    Select Distinct
        AccountCodeID,
        CompanyCode,
        AccountCode,
        AccountDescription
    From General.tbl_AccountCode (NOLOCK)
    Where IsNull(AccountCode, '') Like '%' + Coalesce(@AccountCode, AccountCode, '') + '%'
        And IsNull(AccountDescription, '') Like '%' + '[' + Coalesce(@Description, AccountDescription, '') + ']' + + '%'
        And IsNull(AccountDescription, '') Like '%' + Coalesce(@Description, AccountDescription, '') + '%'
        --And CompanyCode in (Select Code FROM [Sunway_AP].[General].[tbl_Buyer] where GroupID = '9000')
        And CompanyCode = '9000'
    Order By AccountCode
    END
    else
    BEgin
    Select Distinct
        AccountCodeID,
        CompanyCode,
        AccountCode,
        AccountDescription
    From General.tbl_AccountCode (NOLOCK)
    Where IsNull(AccountCode, '') Like '%' + Coalesce(@AccountCode, AccountCode, '') + '%'
        And IsNull(AccountDescription, '') Like '%' + '[' + Coalesce(@Description, AccountDescription, '') + ']' + + '%'
        And IsNull(AccountDescription, '') Like '%' + Coalesce(@Description, AccountDescription, '') + '%'
        And CompanyCode = ISNULL(@CompanyCode, CompanyCode)
    Order By AccountCode
    END

 My requirement is as below:

I have a "Company Dropdown" and a "RadGrid" on Web page with 4 columns inside it:
1) Account Code
2) Description
3) Amount
4) Remark

I want to show only "Account Code(as Dropdown) , Amount(as Textbox), Remark(as Textbox)" column while doing "Edit" and "Add" not "Description" column.

Also, I want that inside "Account Code Dropdown" (which will appear while "edit" and "add") Data for 2 columns: "Account Code" & "Description" should bind together using above Stored Procedure.

and after "adding" records (using Dropdown and textboxes) data should save in DB and visible in RadGrid. Since I want to bind "Account Code Dropdown" together with 2 different DB columns but after "adding" and "editing" records I want to show them in their specific RadGrid columns defined as above.

Also, the binding of "Account Code Dropdown" should be based on Company Dropdown which is outside of RadGrid. i.e., Whatever Company user select from dropdown, data inside "Account Code Dropdown" should be visible based on that particular company.

Data inside Company dropdown is from: 1000 to 9000

RadGrid aspx code is:

<telerik:RadMultiPage ID="RadMultiPage6" runat="server" SelectedIndex="0" Width="100%">
            <telerik:RadPageView ID="RadPageView5" runat="server" Width="100%">
            <telerik:RadAjaxPanel ID="RadAjaxPanel5" runat="server">
 
                <telerik:RadGrid ID="RGGSTAcCode" runat="server" 
                   ShowFooter="True" GroupingEnabled="False" ShowStatusBar="true"       
                   AllowAutomaticInserts="True" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"
                   OnNeedDataSource="RGGSTAcCode_NeedDataSource" OnItemDataBound="RGGSTAcCode_ItemDataBound">
 
                  <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
 
                  <mastertableview ShowHeadersWhenNoRecords="true" commanditemdisplay="Top" autogeneratecolumns="false" datakeynames="RequestID" InsertItemDisplay="Top"
                    insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True" >
                                     
                         <Columns>
                                         
                             <telerik:GridBoundColumn DataField="AccountCodeID" HeaderText="AccountCode ID" UniqueName="AccountCodeID" SortExpression="AccountCodeID"></telerik:GridBoundColumn>
 
                             <telerik:GridBoundColumn DataField="RequestID" HeaderText="Request ID" UniqueName="RequestID" SortExpression="RequestID"></telerik:GridBoundColumn>
 
                             <telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code">
                                            <ItemTemplate>
                                                <asp:Label ID="lblAcCode" Text='<%# Eval("AccountCode") %>' runat="server"></asp:Label>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlAcCode" runat="server"/>
                                            </EditItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                             <telerik:GridBoundColumn DataField="AccountDescription" HeaderText="Description"
                                            UniqueName="AccountDescription" SortExpression="AccountDescription"
                                            InsertVisiblityMode="AlwaysHidden">                                          
                                        </telerik:GridBoundColumn>
          
                             <telerik:GridBoundColumn aggregate="SUM" DataField="Amount" HeaderText="Amount" FooterText="Total : "
                                            UniqueName="Amount" SortExpression="Amount">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />                                          
                                        </telerik:GridBoundColumn>
               
                             <telerik:GridBoundColumn DataField="Remark" HeaderText="IFCA Remark"
                                            UniqueName="Remark" SortExpression="Remark">                                          
                                        </telerik:GridBoundColumn>                                       
                                         
                      </Columns>
 
                      <EditFormSettings>
                       <EditColumn ButtonType="ImageButton" />
                      </EditFormSettings>
                      <CommandItemSettings AddNewRecordText="Add new record" RefreshText="Refresh"></CommandItemSettings>
 
                  </mastertableview>
 
                </telerik:RadGrid>     
                          
            </telerik:RadAjaxPanel>          
            </telerik:RadPageView>
       </telerik:RadMultiPage>
 

Please reply how to achieve it. If Possible guide the solution or create a sample code for my requirement. 

I am very new in Telerik please forgive if something is very basic in my defined requirement.

////

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Priyanka
Top achievements
Rank 1
Share this question
or