Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to update my dynamic grid control values when i click the submit button. it should read all the grid control values in the loop and update in the table when i click statement..
pls. see my code below. (ASPX page)
-------------------------------
<asp:GridView ID="GridView1" runat="server" align="center" AllowPaging="True" DataKeyNames
="Priority"
AutoGenerateColumns="False" class="tabulardata" DataSourceID="SqlDataSource1"
HorizontalAlign="Center" Width="100%" OnRowCommand="GridView1_RowCommand"
OnRowDataBound="GridView1_RowDataBound">
<columns>
>
<asp:TemplateField HeaderText="Sl.No" ItemStyle-HorizontalAlign="Center" ItemStyle-Width
="2%">
<itemtemplate>
>
<asp:Label ID="Sno" runat="server">br mode="hold" />
>
</itemtemplate>br mode="hold" />
>
<itemstyle horizontalalign="Center">
/>
br mode="hold" />
>
<asp:BoundField HeaderText="Project Number" Visible="true" DataField="Priority"
ItemStyle-HorizontalAlign="center" ReadOnly="true" SortExpression="Priority">
<itemstyle horizontalalign="Center" mode="hold" />
="3%"/>
br mode="hold" />
>
<asp:BoundField HeaderText="Current Designation" Visible="true" DataField="Designation"
ItemStyle-HorizontalAlign="center" ReadOnly="true" SortExpression
="Designation">
<itemstyle horizontalalign="Center" mode="hold" />
="25%"/>
br mode="hold" />
>
<asp:TemplateField HeaderText="Professional Role">
<itemtemplate>
>
<asp:DropDownList runat="server" ID="ddlProfRole" width="87%" DataValueField="ProfRoleCode" DataSourceID="SqlDataSource2" DataTextField="ProfRoleDescription">
<asp:ListItem Text="Select" Value="-1">br mode="hold" />
>
</itemtemplate>br mode="hold" />
>
<itemstyle horizontalalign="Center" mode="hold" />
="25%"/>
br mode="hold" />
>
</itemstyle></columns>br mode="hold" />
>
<alternatingrowstyle backcolor="#FFF5F5">
/>
br mode="hold" />
></alternatingrowstyle>


ASPX.VB Code
----------------
VB
Protected Sub ImgbtnSave_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles
ImgbtnSave.Click
'update weeklyload table Values for the PojectNumber
Conn.Open()
StrQry =""
StrQry ="update mppProfRoleMapping set DesignCode='" & & "' where ProfRoleCode ='" & & "'"

Cmd.Connection = Conn
Cmd.CommandText = StrQry
Cmd.ExecuteNonQuery()
Cmd.Dispose()
Conn.Close()
End Sub


please. help

Regards,
Ganesh.S
Posted
Updated 4-Jul-11 6:59am
v2
Comments
thatraja 4-Jul-11 13:01pm    
Your code's format was terrible, But hope I have fixed at least better than previous one.
Please always format the code which is easy to read.

1 solution

Hi, u can use the following code....


VB
Protected Sub ImgbtnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ImgbtnSave.Click
      'update weeklyload table Values for the PojectNumber
      Conn.Open()
      StrQry = ""
      For i As Integer = 0 To GridView1.Rows.Count - 1
          StrQry = "update mppProfRoleMapping set DesignCode='" & CType(GridView1.Rows(i).FindControl("Sno"), Label).Text & "' where ProfRoleCode ='" & CType(GridView1.Rows(i).FindControl("ddlProfRole"), DropDownList).SelectedValue & "'"
      Next

      Cmd.Connection = Conn
      Cmd.CommandText = StrQry
      Cmd.ExecuteNonQuery()
      Cmd.Dispose()
      Conn.Close()
  End Sub
 
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