C# 更改为编辑模式时在gridview中保存复选框的状态
当我在gridview中单击imagebutton时,某些单元格将变得可编辑 但是,它会丢失gridview中的所有复选框值C# 更改为编辑模式时在gridview中保存复选框的状态,c#,asp.net,C#,Asp.net,当我在gridview中单击imagebutton时,某些单元格将变得可编辑 但是,它会丢失gridview中的所有复选框值 protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e) { showWhoIsPublish(); ImageButton i = (ImageButton)e.CommandSource; // אנו מושכים
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
有没有办法保存这些值
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
我创建了一个从xml中获取复选框值的函数,但是,当我在命令时代内调用该函数时,它不起作用
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
当我在gridview中的其他imagebutton命令era中调用该函数时,它不会使某些单元格处于可编辑状态,并且该函数会运行,并且复选框上显示了xml中的值
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
谢谢
<asp:GridView style="direction:rtl; " ShowHeader="False" BorderColor="White" BorderWidth="2px" HeaderStyle-BackColor="#926c3f" HeaderStyle-Font-Bold="false" RowStyle-BorderColor="White" ID="GridView1" runat="server" DataSourceID="XmlDataSource1" AutoGenerateColumns="False" CssClass="auto-style100" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCommand="GridView1_SelectedIndexChanged" OnRowCancelingEdit="GridView1_SelectedIndexChanged" OnRowEditing="GridView1_SelectedIndexChanged" AllowSorting="True">
<Columns>
<asp:TemplateField HeaderText=" שם משחק" ItemStyle-Width="200px" >
<ItemTemplate >
<asp:Label ID="NameLabel" runat="server" Text='<%#Server.UrlDecode(XPathBinder.Eval(Container.DataItem, "gameName").ToString())%>'> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="nameTB" runat="server" Text='<%#Server.UrlDecode(XPathBinder.Eval(Container.DataItem, "gameName").ToString())%>'> </asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="קוד משחק" ItemStyle-Width="85px">
<ItemTemplate>
<asp:Label ID="codeLabel" runat="server" Text='<%#Server.UrlDecode(XPathBinder.Eval(Container.DataItem, "gameCode").ToString())%>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="הגדרות" ItemStyle-Width="70px">
<EditItemTemplate>
<asp:ImageButton ID="cancelImageButton" runat="server" ImageUrl="~/images/cancel.png" CommandName="cancel" OnClientClick="showWhoIsPublish" />
<asp:ImageButton ID="approveImageButton" theItemId='<%#XPathBinder.Eval(Container.DataItem, "@id")%>' runat="server" ImageUrl="~/images/approve.png" CommandName="approve" />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="settingsImageButton" runat="server" CssClass="buttons" ImageUrl="~/images/אייקון הגדרות.png" theItemId='<%#XPathBinder.Eval(Container.DataItem, "@id")%>' CommandName="edit" OnClientClick="showWhoIsPublish" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="עריכה" ItemStyle-Width="70px" >
<ItemTemplate>
<asp:ImageButton ID="editImageButton" runat="server" CssClass="buttons" ImageUrl="~/images/אייקון עריכה.png" theItemId='<%#XPathBinder.Eval(Container.DataItem, "@id")%>' CommandName="editQ" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="מחיקה" ItemStyle-Width="70px">
<ItemTemplate>
<asp:ImageButton ID="deleteImageButton" CssClass="buttons" OnClick="doDelete_Click" theItemId='<%#XPathBinder.Eval(Container.DataItem, "@id")%>' runat="server" ImageUrl="~/images/אייקון מחיקה.png" CommandName="deleteRow" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" הגבלת זמן" ItemStyle-Width="90px" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownListT" AppendDataBoundItems="True" runat="server" >
<asp:ListItem> 10 שניות</asp:ListItem>
<asp:ListItem> 20 שניות</asp:ListItem>
<asp:ListItem> 30 שניות</asp:ListItem>
<asp:ListItem> 40 שניות</asp:ListItem>
<asp:ListItem> 50 שניות</asp:ListItem>
<asp:ListItem> 60 שניות</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate >
<asp:Label ID="Time" runat="server" Text='<%#Server.UrlDecode(XPathBinder.Eval(Container.DataItem, "time").ToString())%>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="פרסום" ItemStyle-Width="60px">
<ItemTemplate>
<asp:CheckBox runat="server" ID="Checkbox1" CssClass="buttons1" theItemId='<%#XPathBinder.Eval(Container.DataItem, "@id")%>' AutoPostBack="True" OnCheckedChanged="PublishYesNo_CheckedChanged" ViewStateMode="Inherit" EnableViewState="True" Checked="False" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
10 שניות
20 שניות
30 שניות
40 שניות
50 שניות
60 שניות
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
protected void GridView1_SelectedIndexChanged(object sender, GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i = (ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId = i.Attributes["theItemId"];
Session["theId"] = theId;
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
switch (e.CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
case "deleteRow":
popOfDelete.Visible = true;
string deleteId = (string)Session["theId"];
string theGameNameDelete = Server.UrlDecode(xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml);
nameOfGameDelete.Text = "'" + theGameNameDelete + "' " + "?";
showWhoIsPublish();
break;
case "editQ":
string editId = (string)Session["theId"];
string theGameNameEdit = xmlDoc.SelectSingleNode("//game[@id='" + (string)Session["theId"] + "']/gameName").InnerXml;
Session["nameOfEdit"] = theGameNameEdit;
Response.Redirect("Default3.aspx");
break;
case "edit":
addNameTB.Text = "jg";
showWhoIsPublish();
break;
case "cancel":
GridView1.DataBind();
showWhoIsPublish();
break;
case "approve":
GridViewRow gvRow = (GridViewRow)(i.Parent.Parent);
string ApproveId = (string)Session["theId"];
int index = gvRow.RowIndex;
string myName = ((TextBox)GridView1.Rows[index].FindControl("nameTB")).Text;
string myValue = ((DropDownList)GridView1.Rows[index].FindControl("DropDownListT")).Text;
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/gameName").InnerText = Server.UrlEncode(myName);
xmlDoc.SelectSingleNode("//game[@id='" + ApproveId + "']/time").InnerText = Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex = -1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
break;
}
}
protected void showWhoIsPublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish = xmlDoc.SelectNodes("/games/user[@id='" + Session["id"] + "']/game/@isPublish");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkItem = (CheckBox)GridView1.Rows[i].FindControl("Checkbox1");
if (myListPublish.Item(i).InnerXml == "yes")
{
chkItem.Checked = true;
}
else
{
chkItem.Checked = false;
}
}
}
protectedvoid GridView1\u SelectedIndexChanged(对象发送方,GridViewCommandEventArgs e)
{
showWhoIsPublish();
ImageButton i=(ImageButton)e.CommandSource;
// אנו מושכים את האי די של הפריט באמצעות מאפיין לא שמור במערכת שהוספנו באופן ידני לכפתור-תמונה
string theId=i.Attributes[“itemid”];
会话[“theId”]=theId;
XmlDocument xmlDoc=XmlDataSource1.GetXmlDocument();
开关(例如CommandName)
{
//אם נלחץ על כפתור מחיקה יקרא לפונקציה של מחיקה
案例“deleteRow”:
popOfDelete.Visible=true;
字符串deleteId=(字符串)会话[“theId”];
字符串theGameNameDelete=Server.UrlDecode(xmlDoc.SelectSingleNode(“//game[@id=”+(字符串)Session[“theId”]+“]/gameName”).InnerXml);
nameOfGameDelete.Text=“”+游戏名称删除+”“+”?”;
showWhoIsPublish();
打破
案例“editQ”:
string editId=(string)会话[“theId”];
string thegamenamedit=xmlDoc.SelectSingleNode(//game[@id=”+(string)Session[“theId”]+“]/gameName”).InnerXml;
会话[“nameOfEdit”]=游戏名称编辑;
重定向(“Default3.aspx”);
打破
案例“编辑”:
addNameTB.Text=“jg”;
showWhoIsPublish();
打破
“取消”案例:
GridView1.DataBind();
showWhoIsPublish();
打破
案例“批准”:
GridViewRow gvRow=(GridViewRow)(i.Parent.Parent);
string approvid=(string)会话[“theId”];
int index=gvRow.RowIndex;
字符串myName=((文本框)GridView1.Rows[index].FindControl(“nameTB”)).Text;
字符串myValue=((DropDownList)GridView1.Rows[index].FindControl(“DropDownList”)).Text;
xmlDoc.SelectSingleNode(“//game[@id=”+approvid+“]/gameName”).InnerText=Server.UrlEncode(myName);
xmlDoc.SelectSingleNode(“//game[@id=”+approvid+“]/time”).InnerText=Server.UrlEncode(myValue);
XmlDataSource1.Save();
// יציאה ממצב של עריכה
GridView1.EditIndex=-1;
// ריענון הגריד ויו
GridView1.DataBind();
showWhoIsPublish();
打破
}
}
受保护的void showhoispublish()
{
//סימון מה שמפורסם
XmlDocument xmlDoc=XmlDataSource1.GetXmlDocument();
XmlNodeList myListPublish=xmlDoc.SelectNodes(“/games/user[@id='”+会话[“id”]+']/games/@isPublish”);
对于(int i=0;i
这是回发问题。。是否正在检查页面上的iPostBack\u加载事件。。?您还可以将值保存在会话对象中。。您也可以在\uuu DoPostBack
函数中编写一些javascript代码来处理此问题,但如果它在每次加载时都运行,则不允许我取消选中复选框(因为加载发生在选中的复选框中的代码更改之前)。我可以用会话保存它们,但我正在寻找一种快捷方式。这是回发问题。。是否正在检查页面上的iPostBack\u加载事件。。?您还可以将值保存在会话对象中。。您也可以在\uuu DoPostBack
函数中编写一些javascript代码来处理此问题,但如果它在每次加载时都运行,则不允许我取消选中复选框(因为加载发生在选中的复选框中的代码更改之前)。我可以通过会话来保存它们,但我正在寻找一种捷径。