与SqlDataSource绑定的GridView...
其中增加了两列TemplateField...其中有TextBox...具体效果如图:
现在想实现这样一个效果:当商品数量TextBox和下一列数据不一致时...
此行背景色变化,并且最后一列变成有改动...
补充说明:此页面继承母版页...希望大家多多帮忙...尽量提供代码...

解决方案 »

  1.   

    你的txt和下列数据不一样不用确定,而是直接输入就判断?
      

  2.   

    该函数加在gridview绑定数据之后
    public void bind()
        {
            for (int i = 0; i < GridView1.Rows.Count - 1; i++)
            {
                GridViewRow myrow = GridView1.Rows[i];
                GridViewRow myrow1 = GridView1.Rows[i+1];
                string fstr = ((TextBox)myrow.Cells[1].FindControl("你那个textbox的id")).Text.Trim();  
                string lstr = ((TextBox)myrow1.Cells[1].FindControl("你那个textbox的id")).Text.Trim();  
               if(fstr!=lstr)
                {
                    GridView1.Rows[i].Cells[6].Text = "有改动";
                    GridView1.Rows[i].BackColor=你需要的颜色;
               }
            }
         }
      

  3.   

    如果商品的数量不是手工输入的.可以在gridview的databound事件中处理,如果是手工输入的话,按就不知道了
      

  4.   

    在databound时间中处理比较容易实现
      

  5.   

    母版页 MasterPage.master<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        <div>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                <asp:TemplateField HeaderText = "ProductName">
                    <ItemTemplate>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" RenderMode="Inline" UpdateMode="Conditional">
                            <ContentTemplate>    
                                <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" AutoPostBack="True"></asp:TextBox>                            
                            </ContentTemplate>
                        </asp:UpdatePanel>        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
                <asp:TemplateField HeaderText="Discontinued" SortExpression="Discontinued">
                    <ItemTemplate>
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="False" RenderMode="Inline" UpdateMode="Conditional">
                            <ContentTemplate>                
                                <asp:Label ID="Label1" runat="server" Text='<%# Convert.ToBoolean(Eval("Discontinued")) == true ? "未改动":"已改动" %>' />
                             </ContentTemplate>
                        </asp:UpdatePanel>                           
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [Discontinued] FROM [Products]"></asp:SqlDataSource>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
        </div>
        </form>
    </body>
    </html>
    MasterPage.master.cs
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }    protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            int rowIndex = ((GridViewRow)t.NamingContainer).RowIndex;
            int productID = Convert.ToInt32(GridView1.DataKeys[rowIndex].Value);
            decimal unitPrice = decimal.Parse(GridView1.Rows[rowIndex].Cells[2].Text);
            
            Label Label1 = (Label)GridView1.Rows[rowIndex].FindControl("Label1");        decimal inputPrice = 0;        if (decimal.TryParse(t.Text, out inputPrice))
            {
                if (inputPrice == unitPrice)
                {
                    Label1.Text = "未改动";
                }
                else
                {
                    Label1.Text = "已改动";
                }
                ((UpdatePanel)GridView1.Rows[rowIndex].FindControl("UpdatePanel1")).Update();
                ((UpdatePanel)GridView1.Rows[rowIndex].FindControl("UpdatePanel2")).Update();
            }
            else
            {
                t.Text = unitPrice.ToString();
                return;
            } 
        }
    }内容页代码随意
      

  6.   

    Net/C#交流区〓 [7729746]
    C# / .Net 交流社团 聊技术,项目合作。[7729746] 〓 .Net/C#交流区〓  绝对 VS平台 牛群....欢迎有项目经验的朋友入群交流。。.附:招管理员(通过 beming 考核)
    Blogs http://zhoufleru.cnblogs.com 
      

  7.   

    终于解决了...
    刚开始的时候落下了:TextBox中AutoPostBack="true"
    又给amandag发了封私信...打扰了...现在明白了...
    谢谢大家...
    结帖去了呃...说点题外话...是不是其实这样做不好啊?每次都得给服务器发送请求...
    得抓紧学习javascript和ajax之类的技术了...