Data GridView选择索引改变了触发问题ASP.NET [英] Data GridView selected index changed firing Problem ASP.NET
本文介绍了Data GridView选择索引改变了触发问题ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i need to select the grid selected row values, in clickevent not firing. can any one helps me
or suggest any other code.
protected void grdTimeSheetEntry_SelectedIndexChanged(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
//string company = GridView1.SelectedRow.Cells[0].Text;
GridViewRow row = grdTimeSheetEntry.SelectedRow;
string c1 = row.Cells[2].Text;
string c2 = row.Cells[3].Text;
string c3 = row.Cells[4].Text;
string c4 = row.Cells[5].Text;
}
}
<asp:GridView ID="grdTimeSheetEntry" runat="server" BackColor="White" BorderColor="#3366CC"
BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="100%"
AllowPaging="True" onpageindexchanging="grdTimeSheetEntry_PageIndexChanging"
onselectedindexchanging="grdTimeSheetEntry_SelectedIndexChanging"
PageSize="15" onpageindexchanged="grdTimeSheetEntry_PageIndexChanged"
onrowcommand="grdTimeSheetEntry_RowCommand"
onselectedindexchanged="grdTimeSheetEntry_SelectedIndexChanged"
AutoGenerateColumns="False">
<RowStyle BackColor="White" ForeColor="#003399" />
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<Columns>
<asp:BoundField DataField="EntryTypeName" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="ProductName" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="VersionNumber" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="BugID" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="SupportID" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="Description" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="Date" Visible="true" ></asp:BoundField>
<asp:BoundField DataField="Effort" Visible="true" ></asp:BoundField>
</Columns>
</asp:GridView>
推荐答案
试试这个:
Try This:
protected void grdTimeSheetEntry_SelectedIndexChanged(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
//string company = GridView1.SelectedRow.Cells[0].Text;
GridViewRow row = grdTimeSheetEntry.SelectedRow;
DropDownList ddl1 = row.FindControl("[your dropdown ID here]");
DropDownList ddl2 = row.FindControl("[your dropdown ID here]");
DropDownList ddl3 = row.FindControl("[your dropdown ID here]");
DropDownList ddl4 = row.FindControl("[your dropdown ID here]");
string c1 = ddl1.Text;
string c2 = ddl2.Text;
string c3 = ddl3.Text;
string c4 = ddl4.Text;
}
}
我认为这是一个错误的事件,你在编写代码。尝试在Dropdownlist selectedindexchanged事件中编写它。只需检查上面的代码是否达到你想要的效果我将告诉你如何在dropdownlist selectedindexchanged事件中做。
I think it is a wrong event in which you are writing the code. Try writing it in the Dropdownlist selectedindexchanged event. Just check if above code achieves what you want else I will tell you how to do in dropdownlist selectedindexchanged event.
试试这些。
GridView.SelectedRow Property [ ^ ]
如何获取细胞使用JQUERY 的gridview值[ ^ ]
如果解决问题,请接受答案。
Try these.
GridView.SelectedRow Property[^]
How to get cell value of gridview using JQUERY[^]
Accept as answer if solve you problem.
只有单击行才能触发事件。你必须在行上有一个Button来处理这个问题。
你可以通过在aspx页面的GridView Mark up中添加以下aproperty来实现。
AutoGenerateSelectButton =True
如果没有按钮,您也可以这样做。
为此尝试在RowDataBound事件中使用以下代码
Only clicking on the Row will not fire the event. You have to have a Button on the row to handle this.
You can do that by adding the below aproperty in the GridView Mark up in aspx page.
AutoGenerateSelectButton="True"
Without the button, you can also do that.
For that try with the below code inside RowDataBound Event
protected void grdTimeSheetEntry_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.grdTimeSheetEntry, "Select
这篇关于Data GridView选择索引改变了触发问题ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文