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

soft save the inserted grid values to datatable

3 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Venkatesh
Top achievements
Rank 1
Venkatesh asked on 04 Dec 2012, 11:52 AM
HI,
I am binding the radgrid using the session variable. The session variable is getting data from a datatable.

Session["GridData"] = datatablevalue ; 
 RadGrid1.DataSource = Session["GridData"];

In the insertcommand, i want to insert the new values to the existing session variable.

How to achieve this?
Thanks

3 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 07 Dec 2012, 08:07 AM
Hello Venkatesh,

I have answered your question in the other thread you have created. We could continue our conversation there or open a formal ticket. Note that we recommend posting individual questions only one because this improves response time and helps our support team give more relevant solutions. Thank you for your understanding.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Venkatesh
Top achievements
Rank 1
answered on 08 Dec 2012, 12:12 PM
Thanks Antonio for the reply.
Before i open up the formal ticket, i would need to make sure the below.

When the page loads, the grid is empty. I am binding the gridtemplate as below:


<telerik:RadGrid ID="RadGrid1" runat="server"  EnableViewState="true" 
        ShowFooter="True" Oninsertcommand="RadGrid1_InsertCommand" 
        onneeddatasource="RadGrid1_NeedDataSource"
    <MasterTableView DataKeyNames="ProductNumber" AutoGenerateColumns="false" EditMode="InPlace" CommandItemDisplay="TopAndBottom" CommandItemSettings-AddNewRecordText="Add New Item"
   
                    <Columns
                     <telerik:GridEditCommandColumn ButtonType="ImageButton"
                        </telerik:GridEditCommandColumn
                        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" 
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px" 
                            ConfirmDialogWidth="220px"
                        </telerik:GridButtonColumn
   
<telerik:GridTemplateColumn DataField="Title" HeaderText="Product Number" UniqueName="ProductNumber" 
                            Visible="true"
                      <InsertItemTemplate
<telerik:RadTextBox ID="RadtxtPrdNumber" runat="server" Text='<%# Bind("ProductNumber") %>' > 
                                </telerik:RadTextBox
                            </InsertItemTemplate
                            <EditItemTemplate
 <telerik:RadTextBox ID="RadtxtPrdNumber" runat="server" Text='<%# Eval("ProductNumber") %>' > 
                                </telerik:RadTextBox
                            </EditItemTemplate
                            <ItemTemplate
<telerik:RadTextBox ID="RadtxtPrdNumber" ReadOnly="true" runat="server" Text='<%# Eval("ProductNumber") %>' /> 
                            </ItemTemplate
                        </telerik:GridTemplateColumn
</Columns
       
    </MasterTableView
     <ClientSettings EnableRowHoverStyle="true"
        </ClientSettings
   
    </telerik:RadGrid>

When no items are available in the grid, i am getting object reference error. In the inserttemplate if i remove the "Bind" code, the object reference error disappers, however i am not able to retrieve the inserted value.

How to fix this?

0
Shinu
Top achievements
Rank 2
answered on 11 Dec 2012, 09:15 AM
Hi,

You can set the text in ItemDataBound event as shown below.
C#:
protected void RadGrid2_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataInsertItem && e.Item.OwnerTableView.IsItemInserted)
    {
        GridDataInsertItem item = (GridDataInsertItem)e.Item;
        RadTextBox txt = (RadTextBox)item.FindControl("RadtxtPrdNumber");
        txt.Text="text";
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Venkatesh
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Venkatesh
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or