Solved

Bind Text to a RadTextBox from a SQL DataSource for updating

Posted on 2011-03-25
5
1,136 Views
Last Modified: 2012-05-11
Hello Experts!  

I am working with Telerik software and creating a very run of the mill RadGrid that pulls data from my SQL table.  I have a completely SEPARATE page that acts as the form that inserts data into this table that populates my grid.  All that is working fine.  

Where I am stuck is UPDATING the data.  I want to use the SAME form to Update my data as I do to Insert my data.  My SQLDataSource is simply querying my table using a querystring and parameter ID.  www.site.com?ID=43

What I can't for the life of me seem to do is Bind a field from the database to my fields on my form.  So simple right??  But I can't get it to work.  Below is the code of my SQLDataSource and just the one little field I am working with.  I have many more, but I am just working with 1 for now.

Can anyone please tell me what I am missing?  What do I need to do differently to get this Bind to work?  Thanks!!

 
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ ConnectionStrings:PositionStatementsConnectionString %>" 
         SelectCommand="SELECT * FROM [Statements] WHERE ([ID] = @ID)" 
         DeleteCommand="DELETE FROM [Statements] WHERE [ID] = @ID" 
         InsertCommand="INSERT INTO [Statements] ([PSTitle]) VALUES (@PSTitle)" 
         UpdateCommand="UPDATE [Statements] SET [PSTitle] = @PSTitle WHERE [ID] = @ID">
         <DeleteParameters>
             <asp:Parameter Name="ID" Type="Int32" />
         </DeleteParameters>
         <InsertParameters>
             <asp:Parameter Name="PSTitle" Type="String" />
         </InsertParameters>
         <SelectParameters>
             <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
         </SelectParameters>
         <UpdateParameters>
             <asp:Parameter Name="PSTitle" Type="String" />
         </UpdateParameters>
</asp:SqlDataSource>


<telerik:RadTextBox ID="PSTitle" Text='<%# Bind("PSTitle") %>' Runat="server" Skin="Web20">
</telerik:RadTextBox>
                         
</form>

Open in new window

0
Comment
Question by:kevingibbs1
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:edzhu
ID: 35220385
The update command has two parameters: PSTitle and ID. However, you just defined one parameter PSTitle. Try to add new parameter for ID.
0
 

Author Comment

by:kevingibbs1
ID: 35220656
Thats right here...isn't it?

         <SelectParameters>
             <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
         </SelectParameters>
0
 
LVL 2

Expert Comment

by:edzhu
ID: 35220666
UPDATE [Statements] SET [PSTitle] = @PSTitle WHERE [ID] = @ID
has two parameters. But in your code, it seems that you just register one parameter for update command. Try the following:
         <UpdateParameters>
             <asp:Parameter Name="PSTitle" Type="String" />
             <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
         </UpdateParameters>

Open in new window

0
 

Accepted Solution

by:
kevingibbs1 earned 0 total points
ID: 35222603
Sorry for the delay edzhu!  Turned out I made a totally different bonehead move!  Sorry about that and thanks for taking the time to help.
0
 

Author Closing Comment

by:kevingibbs1
ID: 35275279
Figured it out on my own.  Sorry.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now