Using edit button with LinqDatasource

  • Thread starter Thread starter Alex. O. Koranteng
  • Start date Start date
A

Alex. O. Koranteng

I have edit button on aspx page. The gridview is using a LinqtoSql query as
datasource for gridview. The edit button is not allowing me to make changes
and does not get enabled. Any suggestions. Will send a zipped file if
required.

Thanks
 
Hello,

Based on my understanding, when you click edit button in GridView, each
item is disabled so that you can't input a new data. If I have
misunderstood you, please feel free to let me know.

After I checked your project, I found you used ReadOnly="True" for each
BoundField in GridView that will disable each field in edit mode. I suggest
you define ReadOnly="True" just for key column. Please check the code as
below:

<asp:BoundField DataField="CustomerID" HeaderText="CustomerID"
ReadOnly="True" SortExpression="CustomerID"></asp:BoundField>
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName"
SortExpression="CompanyName" ></asp:BoundField>
<asp:BoundField DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName" >
</asp:BoundField>
<asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle"
SortExpression="ContactTitle" >
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" >
</asp:BoundField>
<asp:BoundField DataField="City" HeaderText="City"
SortExpression="City" />

Furthermore, I suggest you remove the Select expression to let Update
operation work.

<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="NorthwindDataContext" TableName="Customers"


EnableUpdate="True">
</asp:LinqDataSource>


Sincerely,

Vince Xu

Microsoft Online Support

£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx

£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
 
Back
Top