Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GridView UpdateParameters ReadOnly Issue

Posted on 2009-05-18
2
Medium Priority
?
875 Views
Last Modified: 2012-05-07
I have an Update parameter called "Weekjudge" which corresponds to one of the columns in my GridView".  I need to know the value of this field when the user does an edit so I can pass it back to the server to complete the update.  I'm able to make it work if I set the BoundField's ReadOnly Property to "False".  Problem is, I don't want to allow the user to edit it in the GridView.  In fact, I would prefer to not show the date associated with that field to the user.

I've tried:

(1) setting the BoundField's ReadOnly Property to "true"
(2) setting the BoundField's Visible Property to "false"
(3) setting the GridView's DataKeyNames to "WeekJudge"

   Unfortunately I've not been able to come up with a solution.

What do I try now?
<asp:GridView 
        ID="gridJudge"  
        AllowSorting="false" 
        AllowPaging="false" 
        DataKeyNames="WeekJudge"
        Runat="server"
        DataSourceID="SqlDataSource1"
        AutoGenerateColumns="False" 
        AutoGenerateEditButton="true"
        BorderStyle="Solid" 
        BorderColor="Black" 
        HeaderStyle-BackColor="Black" 
        HeaderStyle-ForeColor="White" RowStyle-BorderColor="Gray" RowStyle-BorderStyle="Solid" RowStyle-BorderWidth="1px"
        >
        <Columns>
          <asp:BoundField ReadOnly="true" HeaderText="Edit" DataField="Edit" SortExpression="Edit" />
          <asp:BoundField ReadOnly="true" HeaderText="Period Type" DataField="PeriodType" />
          <asp:BoundField ReadOnly="true" HeaderText="Period" DataField="PeriodName" />
          <asp:BoundField ReadOnly="true" HeaderText="Bookings" DataField="Bookings" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right"/>
          <asp:BoundField ReadOnly="true" HeaderText="Commits" DataField="Commits" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right"  />
          <asp:BoundField ReadOnly="true" HeaderText="Judges" DataField="Judges" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right" />
          <asp:BoundField ReadOnly="true" HeaderText="Subtotal" DataField="SubTotal" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right" />
          <asp:BoundField HeaderText="Judgment" DataField="Judgment" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right" />
          <asp:BoundField ReadOnly="true" HeaderText="Total" DataField="Total" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right" />
          <asp:BoundField HeaderText="Comment" DataField="Comment" ItemStyle-Width="300px" ItemStyle-BorderColor="Gray" ItemStyle-BorderStyle="Solid" />
          <asp:BoundField ReadOnly="false" HeaderText="WeekJudge" DataField="WeekJudge" />
       </Columns>
      </asp:GridView>
      <asp:SqlDataSource 
        ID="SqlDataSource1" 
        Runat="server" 
        SelectCommandType="StoredProcedure"
        SelectCommand="spJudgeUpload"
        UpdateCommand="spJudgeEdit"
        UpdateCommandType="StoredProcedure"
        ConnectionString="<%$ appSettings:EtgConnectionString %>"
        >
        <UpdateParameters>
            <asp:Parameter Type="String" Name="jUserId" DefaultValue='bsalle'/>
            <asp:Parameter Type="String" Name="WeekJudge" />
            <asp:Parameter Type="Double" Name="Judgment" />
            <asp:Parameter Type="String" Name="Comment" />
        </UpdateParameters>
    </asp:SqlDataSource>

Open in new window

0
Comment
Question by:kerrys57
[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
2 Comments
 
LVL 2

Accepted Solution

by:
kavint earned 1000 total points
ID: 24416766
0
 

Author Comment

by:kerrys57
ID: 24416881
I used the style property to hide the column.
<style type="text/css">
    .hiddencol
    {
        display:none;
    }
    .viscol
    {
        display:block;
    }
</style>
...
<asp:BoundField DataField="WeekJudge" itemstyle-cssclass="hiddencol" />

Open in new window

0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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:…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

604 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