Solved

Bind Text to a RadTextBox from a SQL DataSource for updating

Posted on 2011-03-25
5
1,166 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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