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

how to get values from radgrid and pass as parameters?

3 Answers 381 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 2
Darren asked on 09 Jan 2009, 03:14 PM
Hi there, straight to it!

I have this

    protected void RadGrid1_ItemInserted(object source, Telerik.Web.UI.GridInsertedEventArgs e) 
    { 
        cknetispservicesDataContext db = new cknetispservicesDataContext(); 
        var insertData = db.spInsertData(param1, param2, param3); 
    } 

param1, param2, and param3 should be values that come from my radgrid.
It is RadGrid1_ItemInserted event so i've clicked Insert. When this insert event is fired i want to execute the stored procedure. The stored procedure needs to be passed the parameters from the radgrid, which i want to specify.
Hope i'm clear enough with my problem.


3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Jan 2009, 09:50 AM
Hi Darren,

You can access the newly inserted values in the ItemInserted event as shown below.

CS:
 protected void RadGrid1_ItemInserted(object source, Telerik.Web.UI.GridInsertedEventArgs e) 
    { 
        if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) 
        { 
            GridEditFormInsertItem editformItem = (GridEditFormInsertItem)e.Item; 
            TextBox txtbx = (TextBox)editformItem["ProductName"].Controls[0]; 
            string strtxt = txtbx.Text; 
 
        } 
    } 



Shinu
0
peter
Top achievements
Rank 1
answered on 12 Jan 2009, 12:29 PM
that worked.
but now i've got a foreign key in my database and in my radGrid i have a combobox to select the options. This is giving me problems and i can't pass the parameter?

Keeps telling me that it can't bind the control bound by that name.
            GridEditFormInsertItem editformItem = (GridEditFormInsertItem)e.Item; 
            TextBox txtbxClientId = (TextBox)editformItem["ClientId"].Controls[0]; 
            string ClientId = txtbxClientId.Text; 

This is what my column looks like:
            <telerik:GridTemplateColumn HeaderText="Client" 
                DataType="System.Int64" > 
                    <EditItemTemplate> 
                        <telerik:RadComboBox ID="RadComboBoxClientName" Runat="server"  
                            DataSourceID="LinqDataSourceClient" DataTextField="ClientName"  
                            DataValueField="ClientId" SelectedValue='<%# Bind("ClientId") %>'  
                            Skin="Vista" Width="140px"
                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        </telerik:RadComboBox>                         
                    </EditItemTemplate> 
                     
                    <ItemTemplate> 
                        <%#Eval("tblClient.ClientName")%> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>    

Thank you for your time and help.



0
Darren
Top achievements
Rank 2
answered on 12 Jan 2009, 12:32 PM
that worked.
but now i've got a foreign key in my database and in my radGrid i have a combobox to select the options. This is giving me problems and i can't pass the parameter?

Keeps telling me that it can't bind the control bound by that name.
            GridEditFormInsertItem editformItem = (GridEditFormInsertItem)e.Item; 
            TextBox txtbxClientId = (TextBox)editformItem["ClientId"].Controls[0]; 
            string ClientId = txtbxClientId.Text; 

This is what my column looks like:
            <telerik:GridTemplateColumn HeaderText="Client" 
                DataType="System.Int64" > 
                    <EditItemTemplate> 
                        <telerik:RadComboBox ID="RadComboBoxClientName" Runat="server"  
                            DataSourceID="LinqDataSourceClient" DataTextField="ClientName"  
                            DataValueField="ClientId" SelectedValue='<%# Bind("ClientId") %>'  
                            Skin="Vista" Width="140px"
                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        </telerik:RadComboBox>                         
                    </EditItemTemplate> 
                     
                    <ItemTemplate> 
                        <%#Eval("tblClient.ClientName")%> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>    

Thank you for your time and help.

(sorry bout the previous post my boss was still logged in and i didn't realise)

Tags
Grid
Asked by
Darren
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
peter
Top achievements
Rank 1
Darren
Top achievements
Rank 2
Share this question
or