目前我用response显示((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text,正确显示当前用户名,
但是并没有写入到数据库
html:
<%@ Page Language="C#" MasterPageFile="~/User2/MasterPage.master" AutoEventWireup="true" CodeFile="CaseLV.aspx.cs" Inherits="User2_CaseLV" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
<asp:Button ID="Button3" runat="server" Text="未处理" />
<asp:Button ID="Button4" runat="server" Text="已处理"
PostBackUrl="~/User2/CASELV2.aspx" />
</p>
<p>
<asp:TextBox ID="TextBox1" runat="server" Width="78px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="日期" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="确定" />
</p>
<p>
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"
BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="87px"
onselectionchanged="Calendar1_SelectionChanged" ShowGridLines="True"
Visible="False" Width="57px">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyle BackColor="#FFCC66" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</asp:Calendar>
</p>
<p>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None"
DataKeyNames="id" onrowupdating="GridView1_RowUpdating" >
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField ShowEditButton="True" EditText="选择" UpdateText="确定" />
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id"
InsertVisible="False" ReadOnly="True" Visible="False">
</asp:BoundField>
<asp:BoundField DataField="caseid" HeaderText="caseid"
SortExpression="caseid" >
<ItemStyle Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="aggent" HeaderText="aggent"
SortExpression="aggent" Visible="False" />
<asp:BoundField DataField="folt2" HeaderText="folt2"
SortExpression="folt2" Visible="False" />
<asp:BoundField DataField="folt" HeaderText="folt"
SortExpression="folt" />
<asp:BoundField DataField="casetime" HeaderText="升级时间"
SortExpression="casetime" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MuserConnectionString2 %>"
DeleteCommand="DELETE FROM [caselv] WHERE [id] = @id"
InsertCommand="INSERT INTO [caselv] ([caseid], [aggent], [folt2], [folt], [casetime]) VALUES (@caseid, @aggent, @folt2, @folt, @casetime)"
SelectCommand="SELECT [id], [caseid], [aggent], [folt2], [folt], [casetime] FROM [caselv] WHERE (([casetime] > @casetime) AND ([folt2] = @folt2))"
UpdateCommand="UPDATE [caselv] SET [caseid] = @caseid, [aggent] = getdate(), [folt2] = '已处理', [folt] = @folt, [casetime] = @casetime WHERE [id] = @id">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="casetime" PropertyName="Text"
Type="DateTime" />
<asp:Parameter DefaultValue="未处理" Name="folt2" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="caseid" Type="String" />
<asp:Parameter Name="aggent" Type="DateTime" />
<asp:Parameter Name="folt2" Type="String" />
<asp:Parameter Name="folt" Type="String"/>
<asp:Parameter Name="casetime" Type="DateTime" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="caseid" Type="String" />
<asp:Parameter Name="aggent" Type="DateTime" />
<asp:Parameter Name="folt2" Type="String" />
<asp:Parameter Name="folt" Type="String" />
<asp:Parameter Name="casetime" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
<br />
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>
代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class User2_CaseLV : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string userna = (string)Session["UserName"];
Response.Write(userna);
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
int Ya = Calendar1.SelectedDate.Year;
int Ma = Calendar1.SelectedDate.Month;
int Da = Calendar1.SelectedDate.Day;
TextBox1.Text = (Ya + "/" + Ma + "/" + Da).ToString();
Calendar1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text = (string)Session["UserName"];
}
}
2 个解决方案
#1
。。sqldatasource不会使
#2
直接拖的控件呵呵
#1
。。sqldatasource不会使
#2
直接拖的控件呵呵