Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have made a webpage that will edit the sql database. But in the gridview I want to make a clomn readonly and when I do so Update is not working.

Below is the code:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Test.WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">




<asp:TextBox ID="TextBox1" runat="server" BackColor="#3877C5" Font-Bold="True"
Font-Names="Calibri" Font-Size="X-Large" ForeColor="White" Width="924px"> Software MisMatch Report



<asp:SqlDataSource ID="Vendor" runat="server" ConnectionString="Data Source=10.128.32.190;Initial Catalog=SYBIDEV;Integrated Security=True"

SelectCommand="SELECT DISTINCT Vendor FROM tblFactSoftwareStg">






<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SI" ForeColor="#333333" GridLines="None"
AutoGenerateEditButton="True"
onselectedindexchanged="GridView1_SelectedIndexChanged" PageSize="20"
Font-Names="Calibri">
<alternatingrowstyle backcolor="White" font-bold="False" font-names="Calibri">
Font-Size="Medium" />
<columns> <asp:BoundField DataField="Vendor" HeaderText="Vendor"
SortExpression="Vendor" ReadOnly="True" />
<asp:BoundField DataField="SoftwareName" HeaderText="SoftwareName"
SortExpression="SoftwareName" />
<asp:BoundField DataField="Version" HeaderText="Version"
SortExpression="Version" />
<asp:BoundField DataField="LicenseType" HeaderText="LicenseType"
SortExpression="LicenseType" />
<asp:BoundField DataField="GenericSoftwareName"
HeaderText="GenericSoftwareName" SortExpression="GenericSoftwareName" />
<editrowstyle backcolor="#99CCFF">
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<rowstyle backcolor="#EFF3FB">
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<sortedascendingcellstyle backcolor="#F5F7FB">
<sortedascendingheaderstyle backcolor="#6D95E1">
<sorteddescendingcellstyle backcolor="#E9EBEF">
<sorteddescendingheaderstyle backcolor="#4870BE">

<asp:SqlDataSource ID="SI" runat="server"
ConnectionString="Data Source=10.128.32.190;Initial Catalog=SYBIDEV;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="select distinct Vendor,SoftwareName,Version,LicenseType,GenericSoftwareName from tblFactSoftwareStg where (GenericSoftwareName='NA' or GenericSoftwareName is null or LicenseType='NA' or LicenseType is null) "



UpdateCommand="exec SCCM_Test @Vendor=@Vendor,@SoftwareName=@SoftwareName,@Version=@Version,@LicenseType=@LicenseType,@GenericSoftwareName=@GenericSoftwareName">
<updateparameters>
<asp:Parameter Name="Vendor" />
<asp:Parameter Name="SoftwareName" />
<asp:Parameter Name="Version" />
<asp:Parameter Name="LicenseType" />
<asp:Parameter Name="GenericSoftwareName" />





</form>
</body>
</html>
Posted
Comments
JoCodes 7-Mar-14 0:29am    
Try remove the field from the UpdateCommand. Or you can use Label instead of TextBox control in EditItemTemplate. Try and revert

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900