GridView问题 [英] GridView Problem
本文介绍了GridView问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在GridView控件上使用清单,该控件从数据库中获取布尔值.
效果很好.
我想以这样一种方式进行操作:如果选中了管理者所在的核对清单,则服务器控件(文本框)的可见属性必须为false.
我该怎么办.
Hello all,
I am using checklist on a GridView control which gets bool value from the database.
It work fine.
I want to do it in such a way that if the checklist in the manager''s colunm is checked then a server control (textbox) visible property must be false.
How do I go about this.
Thanks in advance!
推荐答案
在将数据绑定到GridView中以填充链接之后,我正在做类似的事情.可能有更好的方法.
您可以尝试以下操作:
I''m doing something like this right after I bind the data in a GridView to populate links. There is probably a better way.
Off the top of my head, you could try something like this:
foreach (GridViewRow gvr in dgSupervisor2.Rows)
{
CheckBox selectedCheckbox = (LinkButton)gvr.FindControl("checkBox");
if (selectButton != null)
{
int i = gvr.RowIndex;
TableCellCollection MyCells = Manager.Rows[i].Cells;
TextBox ToDisable = MyCells[5]; //Adjust this number to the column location of the textbox
if (selectedCheckbox.Checked == true)
{
ToDisable.Enabled = false;
}
}
}
但是请检查以确保我的语法正确.
But check to make sure my syntax is right.
有人请告诉我为什么此代码不起作用:
受保护的sub nextOfKinGridView_RowUpdating(ByVal发送者作为对象,ByVal e作为System.Web.UI.WebControls.GridViewUpdateEventArgs)处理nextOfKinGridView.RowUpdating
Dim _nextofkinid As Int32 = CInt(Me.nextOfKinGridView.Rows(e.RowIndex).Cells(0).Text)``亲爱的ID的下一个
Dim _Surname As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(1).Controls(0),TextBox).Text
Dim _FirstName as String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(2).Controls(0),TextBox).Text
Dim _OtherNames As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(3).Controls(0),TextBox).Text
Dim _ContactAddress为字符串= CType(nextOfKinGridView.Rows(e.RowIndex).Cells(4).Controls(0),TextBox).Text
Dim _Telephone As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(5).Controls(0),TextBox).Text
昏暗_电子邮件作为字符串= CType(nextOfKinGridView.Rows(e.RowIndex).Cells(6).Controls(0),TextBox).Text
Dim _Relationship As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(7).Controls(0),TextBox).Text
试试
BAL.Recruitment.UpdateEmployeeNextOfKin(_nextofkinid,_Surname,_FirstName,_OtherNames,_ContactAddress,_Telephone,_
_Email,_Relationship)
nextOfKinGridView.EditIndex = -1
BindNextOfKinGridview()
异常捕获
Me.kinMessageLabel.Text = ex.Message()
结束尝试
结束Sub
Somebody please tell me why this code is not working:
Protected Sub nextOfKinGridView_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles nextOfKinGridView.RowUpdating
Dim _nextofkinid As Int32 = CInt(Me.nextOfKinGridView.Rows(e.RowIndex).Cells(0).Text) ''Next Of Kin ID
Dim _Surname As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(1).Controls(0), TextBox).Text
Dim _FirstName As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text
Dim _OtherNames As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(3).Controls(0), TextBox).Text
Dim _ContactAddress As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(4).Controls(0), TextBox).Text
Dim _Telephone As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(5).Controls(0), TextBox).Text
Dim _Email As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(6).Controls(0), TextBox).Text
Dim _Relationship As String = CType(nextOfKinGridView.Rows(e.RowIndex).Cells(7).Controls(0), TextBox).Text
Try
BAL.Recruitment.UpdateEmployeeNextOfKin(_nextofkinid, _Surname, _FirstName, _OtherNames, _ContactAddress, _Telephone, _
_Email, _Relationship)
nextOfKinGridView.EditIndex = -1
BindNextOfKinGridview()
Catch ex As Exception
Me.kinMessageLabel.Text = ex.Message()
End Try
End Sub
这篇关于GridView问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文