[英]Selecting row of DataGridView?
How do i have the whole row of a data grid view. 如何获得数据网格视图的整行。 I have no idea where to start. 我不知道从哪里开始。 I have tried this, but has NO idea where to PUT it. 我已经尝试过了,但是不知道在哪里放置它。 : :
dataGrid.Rows[index].Selected = true;
I am just looking for a peice of code that will help me! 我只是在寻找对我有帮助的代码! Thanks 谢谢
It seems you want to do something like this: 看来您想执行以下操作:
protected void Page_Load(object sender, EventArgs e)
{
this.FillGrid();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
this.GridView1.SelectedIndex = e.NewSelectedIndex;
this.FillGrid();
}
private void FillGrid()
{
this.GridView1.DataSource = new[] { "Hello", "World" };
this.GridView1.DataBind();
}
And in the aspx file: 并在aspx文件中:
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanging="GridView1_SelectedIndexChanging">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
</asp:GridView>
Which produces this output: 产生以下输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.