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

How to insert a recod into databse

5 Answers 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
victor
Top achievements
Rank 1
victor asked on 12 May 2011, 04:47 PM
Hi,
I have develop a small asp.net Ajax Radcontrole in that i am using a Rad Grid When i try to inset a new record into database it doesn't store into database but it showing the record in grid as temporary .i have given my database connection in web.config and that connection sting name given in      
 <sds:SessionDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
This is only i have changed ....Please help me how resolve this problem.....

5 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 12 May 2011, 09:43 PM
Hello Victor,

You have to replace the SessionDataSource control with SqlDataSource as explained in the following link:
Instructions

Best regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
victor
Top achievements
Rank 1
answered on 13 May 2011, 07:12 AM
Hi Daniel,
       Thank you for giving a quick responce i have replace SessionDataSource control  with SqlDataSource and it is working fine .
But,when i click any action(Add,Edit,Delete) button on Rad Grid it showing a message box ( i have attach a screen shot what message box showing)
how can i stop this message box please help me....
0
victor
Top achievements
Rank 1
answered on 16 May 2011, 03:57 PM
Hi Team,

    i have small issue that i am using radgrid control in asp.net Ajax in that i have store a record into database (imagename,discription,Image) it is working fine ,but now here i want get the image path and i store this image name into another database  how can i get that path name from code behind(c#) please help me.....Here i post my code please check it once 

  <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
     
        <telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" Width="97%" DataSourceID="SessionDataSource1" AllowAutomaticInserts="true"
            AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" ShowStatusBar="True"
            GridLines="None" OnItemCommand="Radgrid_Itemcommand" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" PageSize="3">
            <PagerStyle Mode="NumericPages" AlwaysVisible="true" />
            <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="ID" DataSourceID="SessionDataSource1">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton">
                        <HeaderStyle Width="3%" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridTemplateColumn HeaderText="Image Name" UniqueName="ImageName" SortExpression="Name">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblName" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" Width="200px" ID="txbName" Text='<%# Bind("Name") %>' />
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="txbName" ErrorMessage="Please, enter a name!" Display="Dynamic" SetFocusOnError="true" />
                        </EditItemTemplate>
                        <HeaderStyle Width="30%" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Description" UniqueName="Description" DataField="Description">
                        <ItemTemplate>
                            <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description")%>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox ID="txbDescription" Width="300px" runat="server" TextMode="MultiLine"
                                Text='<%# Bind("Description") %>' Height="150px" />
                        </EditItemTemplate>
                        <ItemStyle VerticalAlign="Top" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBinaryImageColumn  DataField="Data" HeaderText="Image" UniqueName="Upload" ImageAlign="NotSet"
                        ImageHeight="80px" ImageWidth="80px" ResizeMode="Fit" DataAlternateTextField="Description"
                        DataAlternateTextFormatString="Image of {0}">
                        <HeaderStyle Width="10%" /> 
                    </telerik:GridBinaryImageColumn>
                    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton">
                        <HeaderStyle Width="2%" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" UniqueName="test"/>
                </EditFormSettings>
            </MasterTableView> 
        </telerik:RadGrid> 
    </telerik:RadAjaxPanel>
      <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Mybusinessconnection %>"
      ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Mybusinessapp_Pictures]" InsertCommand="INSERT INTO [Mybusinessapp_Pictures] ([Name], [Description], [Data]) VALUES (@Name, @Description, @Data)"
        UpdateCommand="UPDATE [Mybusinessapp_Pictures] SET [Name] = @Name, [Description] = @Description, [Data] = @Data WHERE [ID] = @ID"
        DeleteCommand="DELETE FROM [Mybusinessapp_Pictures] WHERE [ID] = @ID">
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Data" DbType="Binary" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
       
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
      </asp:SqlDataSource>
0
victor
Top achievements
Rank 1
answered on 17 May 2011, 09:41 AM
hi ,
i m using RadAsyncUpload in my form. it use for ,ultifile upload. my requirement is if when file upload that time file is store in my project folder at the same time it will be stored into database. my code is in codebehind. but it gives error every time like following.

Could not find file App_Data\RadUploadTemp\xrdglyzs.lrr'.
here in error bold portion is always different. and my application quit

and my code is following..

GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem;
        string imageName = (insertItem["ImageName"].FindControl("txbName") as RadTextBox).Text;
        string description = (insertItem["Description"].FindControl("txbDescription") as RadTextBox).Text;
        RadAsyncUpload radAsyncUpload = insertItem["Upload"].FindControl("AsyncUpload1") as RadAsyncUpload;
        UploadedFile file = radAsyncUpload.UploadedFiles[0];

        if (radAsyncUpload.UploadedFiles.Count > 0)
        {
            foreach (UploadedFile uploadedFile in radAsyncUpload.UploadedFiles)
            {
                int bytesRead = 0;
                byte[] documentData = new byte[uploadedFile.ContentLength];
                bytesRead = uploadedFile.InputStream.Read(documentData, 0, uploadedFile.ContentLength);
                // No need to show more code, it breaks here w/ FileNotFoundException...
            }
        }
but it always fail

so.. please help me.
0
Daniel
Telerik team
answered on 19 May 2011, 02:19 PM
Hello Victor,

You have to create your own custom handler in order to manipulate the files this way.
Please examine the following links:

Regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
victor
Top achievements
Rank 1
Answers by
Daniel
Telerik team
victor
Top achievements
Rank 1
Share this question
or