GlobalVariable.SetValue(24, DgdEmpInfo.Items[e.Item.ItemIndex].Cells[0]Text);我想将在我点击datagrid上的按钮列(编辑)时将对应行(x)的第一单元格cell(0
)的值放入变量GlobalVariable(24),datagrid的的第一列是SCHID,由数据库自动生成的序号.可是我用开头的语句读出来是空值,但我读其他列比如GlobalVariable.SetValue(24, DgdEmpInfo.Items[e.Item.ItemIndex].Cells[1]Text);是可以读出正确值的,难道的一列的cells的index不对马?求教,谢谢
)的值放入变量GlobalVariable(24),datagrid的的第一列是SCHID,由数据库自动生成的序号.可是我用开头的语句读出来是空值,但我读其他列比如GlobalVariable.SetValue(24, DgdEmpInfo.Items[e.Item.ItemIndex].Cells[1]Text);是可以读出正确值的,难道的一列的cells的index不对马?求教,谢谢
this.textBox1.DataBindings.Add("属性名",数据源,"要帮定到的属性或列表");
<asp:DataGrid ID="DgdEmpInfo" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="#F7F7F7" BorderColor="#F7F7F7" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" CssClass="table" DataKeyField="SchID" Font-Name="Verdana" Font-Names="Verdana"
HeaderStyle-BackColor="#d8c8a8" HeaderStyle-font-weight="fold" Height="81px"
PageSize="15" Width="97%" OnItemCommand="DgdEmpInfo_ItemCommand " >
<FooterStyle CssClass="headcenter" Font-Size="X-Small" /><EditItemStyle BackColor="Black" ForeColor="Black" /><SelectedItemStyle BackColor="Transparent" /><PagerStyle Mode="NumericPages" /><AlternatingItemStyle BackColor="White" BorderColor="White" /><ItemStyle BackColor="#DEDFDE" CssClass="textcenter" /><HeaderStyle BackColor="#D8C8A8" CssClass="headcenter" />
<Columns>
<asp:HyperLinkColumn HeaderText="序号" DataTextField="SchID">
<ItemStyle Wrap="False"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="EmpName" HeaderText="角色名"></asp:BoundColumn>
<asp:BoundColumn DataField="LedID" HeaderText="显示屏编号"></asp:BoundColumn>
<asp:BoundColumn DataField="LedName" HeaderText="显示屏名称"></asp:BoundColumn>
<asp:BoundColumn DataField="DutyBeginTime" HeaderText="开始时间"></asp:BoundColumn>
<asp:BoundColumn DataField="DutyEndTime" HeaderText="结束时间"></asp:BoundColumn>
<asp:BoundColumn DataField="AllowBright" HeaderText="亮度"></asp:BoundColumn>
<asp:BoundColumn DataField="AllowPower" HeaderText="关屏"></asp:BoundColumn>
<asp:ButtonColumn HeaderText="详细" CommandName="AllInfo" Text="<img src=../Img/details.gif border=0 alt=浏览此详细信息 />"></asp:ButtonColumn>
<asp:ButtonColumn HeaderText="编辑" CommandName="Edit" Text="<img src=../Img/edit.gif border=0 alt=更改此信息 />"></asp:ButtonColumn>
<asp:ButtonColumn HeaderText="删除" CommandName="Delete" Text="<img src=../Img/delete.gif border=0 alt=删除LED信息 onclick="JavaScript:return confirm('确定删除吗?')"/> "></asp:ButtonColumn>
<asp:BoundColumn DataField="EmpID" Visible="False"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
因为第一行是个超链接列,因此不能直接取Text,要:
string tmp = ((HyperLink)DgdEmpInfo.Items[e.Item.ItemIndex].Cells[0].Controls[0]).Text;