Solved

Bind Text to a RadTextBox from a SQL DataSource for updating

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Error 11 47
Error on link 14 38
Visual Studio TFS - how do I check in my code? 2 29
C#.NET and microsoft certification. 3 34
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

15 Experts available now in Live!

Get 1:1 Help Now