Update ASP.Net GridView cell with Stored Procedure using C# and VB.Net in ASP.Net

Last Reply 18 days ago By Andrea

Posted 18 days ago

I have a GridView that gets the data from a StoreProcedure in SQL. now I want to update some field in that grid. how can I update that ?

my table, view and also StoreProcedure is shown below:

 my view is:

SELECT dbo.EDU_Person.FirstName, dbo.EDU_Person.LastName, dbo.EDU_Student1.PersonId, dbo.EDU_Lesson2.Title, dbo.EDU_Student1.code, dbo.EDU_Lesson2.Mark
FROM dbo.EDU_Student1 
INNER JOIN dbo.EDU_Person ON dbo.EDU_Student1.PersonId = dbo.EDU_Person.Id 
INNER JOIN dbo.EDU_Lesson2 ON dbo.EDU_Student1.Id = dbo.EDU_Lesson2.StudentId

And my SP is:

Create Procedure myproc @id int
select * from View_Sample
where PersonId=@id

the GridView code is:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="455px">
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
        <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
        <asp:BoundField DataField="PersonId" HeaderText="PersonId" SortExpression="PersonId" />
        <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
        <asp:BoundField DataField="code" HeaderText="code" SortExpression="code" />
        <asp:BoundField DataField="Mark" HeaderText="Mark" SortExpression="Mark" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="myproc" SelectCommandType="StoredProcedure">
        <asp:Parameter DefaultValue="1" Name="id" Type="Int32" />

Now how can I update the Mark field in my gridview and update the EDU_Lesson2 ?