?
Solved

Bind Text to a RadTextBox from a SQL DataSource for updating

Posted on 2011-03-25
5
Medium Priority
?
1,193 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

862 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