?
Solved

Bind Text to a RadTextBox from a SQL DataSource for updating

Posted on 2011-03-25
5
Medium Priority
?
1,174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

743 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