C# 更新面板工作不正常
我将Gridview包装在更新面板中,并将触发器设置为搜索按钮,但它无法正常工作, 当我将文本放入文本框并单击“搜索”,然后gridview显示相关结果时,这没关系,但它应该在单击gridview的“选择”按钮时将列的文本加载到文本框中,该按钮在放入“更新”面板之前起作用,但现在不起作用。它既不会将文本加载到文本框中,也不会在单击搜索按钮后再次加载 代码:C# 更新面板工作不正常,c#,asp.net,updatepanel,C#,Asp.net,Updatepanel,我将Gridview包装在更新面板中,并将触发器设置为搜索按钮,但它无法正常工作, 当我将文本放入文本框并单击“搜索”,然后gridview显示相关结果时,这没关系,但它应该在单击gridview的“选择”按钮时将列的文本加载到文本框中,该按钮在放入“更新”面板之前起作用,但现在不起作用。它既不会将文本加载到文本框中,也不会在单击搜索按钮后再次加载 代码: 找不到此输入的数据。再试一次。 受保护的无效网格视图\u SelectedIndexChanged(对象发送方,事件参数e) { Grid
找不到此输入的数据。再试一次。
受保护的无效网格视图\u SelectedIndexChanged(对象发送方,事件参数e)
{
GridViewRow行=gridViewComplaints.SelectedRow;
txtComplaintSubject.Text=行。单元格[2]。文本;
HiddenFieldComplaintID.Value=行。单元格[1]。文本;
int cid=转换为32(HiddenFieldComplaintID.Value);
Response.Write(cid.ToString());
gridViewComplaints.Visible=false;
}
这就是我的工作方式。如果您可以尝试此代码:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" class="gridview" OnRowCommand="EditGridData" runat="server"
AutoGenerateColumns="False" CellPadding="4" GridLines="None" AllowPaging="True"
OnPageIndexChanging="GrdState_PageIndexChanging" PageSize="20" EmptyDataText="Record is Not Available"
Width="93%">
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="BtnEdit" runat="server" CausesValidation="false" class="black skin_colour round_all"
CommandArgument='<%# Eval("Country_ID")%>' CommandName="Edit1" ForeColor="#6699FF"
Font-Underline="True"> <span>Edit</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="BtnDelete" OnClientClick="return confirm('Are you sure want to delete?');"
CausesValidation="false" class="black skin_colour round_all " CommandArgument='<%# Eval("Country_ID")%>'
CommandName="Delete1" runat="server" ForeColor="#6699FF" Font-Underline="True"><span>Delete</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="LBtnView" CausesValidation="false" class="black skin_colour round_all "
CommandArgument='<%# Eval("Country_ID")%>' CommandName="View1" runat="server"
ForeColor="#6699FF" Font-Underline="True"><span>View</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Country_Name" HeaderText="Country" />
<asp:BoundField DataField="Description" Visible="false" HeaderText="Description" />
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<div class="DisplayDiv">
<asp:Label ID="Label1" runat="server" CssClass="DisplayDesc" Text='<%# Eval("Description") %>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CreationDate" HeaderText="Creation Date" DataFormatString="{0:dd/MM/yy}" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
希望这能有所帮助。您能解释一下您发布的代码中有什么是对此处出现的问题的答案,以便用户和未来的读者可以从中学习吗?
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" class="gridview" OnRowCommand="EditGridData" runat="server"
AutoGenerateColumns="False" CellPadding="4" GridLines="None" AllowPaging="True"
OnPageIndexChanging="GrdState_PageIndexChanging" PageSize="20" EmptyDataText="Record is Not Available"
Width="93%">
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="BtnEdit" runat="server" CausesValidation="false" class="black skin_colour round_all"
CommandArgument='<%# Eval("Country_ID")%>' CommandName="Edit1" ForeColor="#6699FF"
Font-Underline="True"> <span>Edit</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="BtnDelete" OnClientClick="return confirm('Are you sure want to delete?');"
CausesValidation="false" class="black skin_colour round_all " CommandArgument='<%# Eval("Country_ID")%>'
CommandName="Delete1" runat="server" ForeColor="#6699FF" Font-Underline="True"><span>Delete</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="LBtnView" CausesValidation="false" class="black skin_colour round_all "
CommandArgument='<%# Eval("Country_ID")%>' CommandName="View1" runat="server"
ForeColor="#6699FF" Font-Underline="True"><span>View</span></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Country_Name" HeaderText="Country" />
<asp:BoundField DataField="Description" Visible="false" HeaderText="Description" />
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<div class="DisplayDiv">
<asp:Label ID="Label1" runat="server" CssClass="DisplayDesc" Text='<%# Eval("Description") %>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CreationDate" HeaderText="Creation Date" DataFormatString="{0:dd/MM/yy}" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
public void EditGridData(object sender, GridViewCommandEventArgs e)
{
int i = Convert.ToInt32(e.CommandArgument);
Session["Country_ID"] = i;
if (e.CommandName == "Edit1")
{
SortedList sl = new SortedList();
sl.Add("@mode", "GetRows1");
sl.Add("@Country_ID", i);
SqlDataReader dr = emp.GetDataReaderSP("CountryMaster1", sl);
while (dr.Read())
{
txtCountry.Text = dr["Country_Name"].ToString();
txtDesc.Text = dr["Description"].ToString();
ViewState["Country_Name"] = dr["Country_Name"].ToString();
BtnSubmit.Visible = true;
BtnSubmit.Text = "Update";
}
}
if (e.CommandName == "View1")
{
SortedList sl = new SortedList();
sl.Add("@mode", "GetRows1");
sl.Add("@Country_ID", i);
SqlDataReader dr = emp.GetDataReaderSP("CountryMaster1", sl);
while (dr.Read())
{
txtCountry.Text = dr["Country_Name"].ToString();
txtDesc.Text = dr["Description"].ToString();
ViewState["Country_Name"] = dr["Country_Name"].ToString();
BtnReset.Visible = true;
BtnSubmit.Visible = false;
}
}
if (e.CommandName == "Delete1")
{
SortedList sl = new SortedList();
sl.Add("@mode", "DeleteData");
sl.Add("@Country_ID", i);
emp.ExecuteNonQuerySP("CountryMaster1", sl);
Label1.Visible = true;
Label1.Text = "Record Deleted Successfully…";
BindGrid();
}
}