编辑该行项目后如何永久更改Gridview行颜色 [英] how to change Gridview Row Color Permnently after Editing items Of that Row

查看:65
本文介绍了编辑该行项目后如何永久更改Gridview行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有一个网格视图,通过单击该链接按钮,我有一个名为链接按钮的项目模板,Ajax弹出扩展程序将出现,用户将编辑项目..编辑后,行颜色"应更改为其他颜色.永久改变 ..我该如何实现

谢谢

hi all
I have one grid view in that i have item template called link button by clicking on that link button Ajax popup extender will appear and user Edits the items.. After editing the Row Color should Change to some other color.. Colors should Change Permanently.. How Can i Achieve this

Thanks

推荐答案

The code below populates a gridview control which has all its rows'' ForeColor set to Drawing.Color.Blue. The Page_Load routine runs fine as the gridview appears with all the right data in Blue. Upon clicking btnSelect, the debugger starts off in Page_Load, skips over the subroutine because it is a postback, then jumps into the btnSelect_Click code, sets all the gv.Rows ForeColor to Red and exits. The page reappears from debug and the gridview ForeColor is still Blue!! I cannot figure this one out. Anybody out there have any (polite) suggestions? My first experience with the gridview.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If (Not Page.IsPostBack) Then
cn = Session("Connection")

If (cn.State.ToString = "Closed") Then cn.Open()
cmd = New SqlCommand("SelectAllStores", cn)

cmd.CommandType = Data.CommandType.StoredProcedure

sdr = cmd.ExecuteReader

If (sdr.HasRows) Then

gv.DataSource = sdr

gv.DataBind()

End If

sdr.Close()

cmd.Dispose()

End If

End Sub

 
Protected Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _

Handles btnSelect.Click

Dim i As Integer
For i = 0 To gv.Rows.Count - 1

gv.Rows(i).ForeColor = Drawing.Color.Red


这篇关于编辑该行项目后如何永久更改Gridview行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆