我需要更新sql表然后在页面回发时可以绑定数据。我不想在gridview中编辑。
我的aspx代码......
<asp:GridView ID="VRGridservicefee" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" Width="100%" EmptyDataText="No Records Added"
DataKeyNames="V16_TRANID" DataSourceID="SqlDataSource1_V16_VEN_SER_FEE" OnRowUpdating="VRGridservicefee_RowUpdating">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="Update" runat="server" Text="Delete"
OnClientClick="javascript:return confirm('Are you sure you want to delete this Fee?');" /></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="V16_TRANID" HeaderText="Vendor ser ID" />
<asp:BoundField DataField="V16_V13TRANID" HeaderText="Vendor ID" />
<asp:BoundField DataField="V16_SERVICES" HeaderText="Service" />
<asp:BoundField DataField="V16_CURRENCY" HeaderText="Service Currency" />
<asp:BoundField DataField="V16_FEES" HeaderText="Service Fees" />
<asp:BoundField DataField="V16_REM" HeaderText="Service Remarks" ItemStyle-Wrap="true"
ItemStyle-Width="90 px" ItemStyle-HorizontalAlign="Left" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" Font-Names="Verdana" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" Font-Names="Verdana"
HorizontalAlign="Left" VerticalAlign="Middle" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" Font-Names="Verdana" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" Font-Names="Verdana" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" Font-Names="Verdana" />
<SortedAscendingCellStyle BackColor="#FFF1D4" Font-Names="Verdana" />
<SortedAscendingHeaderStyle BackColor="#B95C30" Font-Names="Verdana" />
<SortedDescendingCellStyle BackColor="#F1E5CE" Font-Names="Verdana" />
<SortedDescendingHeaderStyle BackColor="#93451F" Font-Names="Verdana" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1_V16_VEN_SER_FEE" runat="server" ConnectionString="<%$ ConnectionStrings:VMSTEST %>"
SelectCommand="SELECT [V16_TRANID], [V16_V13TRANID], [V16_SERVICES], [V16_CURRENCY], [V16_FEES], [V16_REM] FROM [V16_VEN_SER_FEE] WHERE ([V16_V13TRANID] = @V16_V13TRANID) and V16_Status = 'A'">
<SelectParameters>
<asp:ControlParameter ControlID="VDtranid" Name="V16_V13TRANID" PropertyName="Text"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
我的.cs代码
protected void VRGridservicefee_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
con.Open();
//Label tranidid = VRGridservicefee.Rows[e.RowIndex].FindControl("V16_TRANID") as Label;
//TextBox tranidid = (TextBox)VRGridservicefee.Rows[e.RowIndex].FindControl("V16_TRANID");
int tranidid = Convert.ToInt32(VRGridservicefee.DataKeys[e.RowIndex].Values[0]);
SqlCommand updategrid = new SqlCommand("update V16_VEN_SER_FEE set V16_STATUS='I' where V16_TRANID = @v16tranid", con);
updategrid.Parameters.AddWithValue("@v16tranid",tranidid);
updategrid.ExecuteNonQuery();
con.Close();
VRGridservicefee.DataBind();
}
我需要将特定行V16_tranid作为更新sql的条件...简单..无法找到任何解决方案。我只想做后面的代码。