Hi nauna,
I have created sample with more than 100 resource key. You can refer the below code and screenshot.
HTML
UpdateResource.aspx
<div>
<asp:DropDownList ID="cmbResources" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cmbResources_SelectedIndexChanged"
Width="275px">
</asp:DropDownList>
<br />
<br />
<asp:DataGrid ID="gridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" Width="275px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%= ++indexNum %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Key">
<ItemTemplate>
<%# DataBinder.Eval(Container,"DataItem.Key") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Value">
<ItemTemplate>
<%# DataBinder.Eval(Container,"DataItem.Value") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<a href='editresource.aspx?key=<%# DataBinder.Eval(Container,"DataItem.Key") %>&file=<%=cmbResources.SelectedItem.Text %>&id=<%=indexNum - 1 %>'>
Edit</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#FFFBD6" ForeColor="#333333" Font-Size="Small" Font-Names="verdana" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
</asp:DataGrid>
<br />
</div>
UpdateResource.aspx.cs
public int indexNum = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string resourcespath = Request.PhysicalApplicationPath + "App_GlobalResources";
DirectoryInfo dirInfo = new DirectoryInfo(resourcespath);
foreach (FileInfo filInfo in dirInfo.GetFiles())
{
string filename = filInfo.Name;
cmbResources.Items.Add(filename);
}
cmbResources.Items.Insert(0, new ListItem("Select a Resource File"));
}
}
protected void cmbResources_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbResources.SelectedIndex != 0)
{
string filename = Request.PhysicalApplicationPath + "App_GlobalResources\\" + cmbResources.SelectedItem.Text;
Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
ResXResourceReader RrX = new ResXResourceReader(stream);
IDictionaryEnumerator RrEn = RrX.GetEnumerator();
SortedList slist = new SortedList();
while (RrEn.MoveNext())
{
slist.Add(RrEn.Key, RrEn.Value);
}
RrX.Close();
stream.Dispose();
gridView1.DataSource = slist;
gridView1.DataBind();
}
}
UpdateResource.aspx.vb
Public indexNum As Integer = 0
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
Dim resourcespath As String = Request.PhysicalApplicationPath + "App_GlobalResources"
Dim dirInfo As New DirectoryInfo(resourcespath)
For Each filInfo As FileInfo In dirInfo.GetFiles()
Dim filename As String = filInfo.Name
cmbResources.Items.Add(filename)
Next
cmbResources.Items.Insert(0, New ListItem("Select a Resource File"))
End If
End Sub
Protected Sub cmbResources_SelectedIndexChanged(sender As Object, e As EventArgs)
If cmbResources.SelectedIndex <> 0 Then
Dim filename As String = Request.PhysicalApplicationPath + "App_GlobalResources\" + cmbResources.SelectedItem.Text
Dim stream As Stream = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim RrX As New ResXResourceReader(stream)
Dim RrEn As IDictionaryEnumerator = RrX.GetEnumerator()
Dim slist As New SortedList()
While RrEn.MoveNext()
slist.Add(RrEn.Key, RrEn.Value)
End While
RrX.Close()
stream.Dispose()
gridView1.DataSource = slist
gridView1.DataBind()
End If
End Sub
editresource.aspx
<div style="font-size: 14pt; width: 280px; font-family: Verdana; height: 150px; border-right: #ff33ff thin solid;
border-top: #ff33ff thin solid; vertical-align: middle; border-left: #ff33ff thin solid;
border-bottom: #ff33ff thin solid; color: #0000ff;">
<asp:Label ID="Label1" runat="server"></asp:Label>:<asp:TextBox ID="txtResourceValue"
runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Update" OnClick="Button1_Click" />
<asp:Label ID="Label2" runat="server"></asp:Label><br />
<br />
<a href="UpdateResource.aspx">Back</a>
</div>
editresource.aspx.cs
public string filename;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filename = Request.QueryString["file"];
filename = Request.PhysicalApplicationPath + "App_GlobalResources\\" + filename;
string key = Request.QueryString["key"];
Label1.Text = key;
ResXResourceSet rset = new ResXResourceSet(filename);
txtResourceValue.Text = rset.GetString(key);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
filename = Request.QueryString["file"];
int id = Convert.ToInt32(Request.QueryString["id"]);
filename = Request.PhysicalApplicationPath + "App_GlobalResources\\" + filename;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename);
XmlNodeList nlist = xmlDoc.GetElementsByTagName("data");
XmlNode childnode = nlist.Item(id);
childnode.Attributes["xml:space"].Value = "default";
xmlDoc.Save(filename);
XmlNode lastnode = childnode.SelectSingleNode("value");
lastnode.InnerText = txtResourceValue.Text;
xmlDoc.Save(filename);
Label2.Text = "Resource File Updated Successfully.";
}
editresource.aspx.vb
Public filename As String
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
filename = Request.QueryString("file")
filename = Convert.ToString(Request.PhysicalApplicationPath + "App_GlobalResources\") & filename
Dim key As String = Request.QueryString("key")
Label1.Text = key
Dim rset As New ResXResourceSet(filename)
txtResourceValue.Text = rset.GetString(key)
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs)
filename = Request.QueryString("file")
Dim id As Integer = Convert.ToInt32(Request.QueryString("id"))
filename = Convert.ToString(Request.PhysicalApplicationPath + "App_GlobalResources\") & filename
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(filename)
Dim nlist As XmlNodeList = xmlDoc.GetElementsByTagName("data")
Dim childnode As XmlNode = nlist.Item(id)
childnode.Attributes("xml:space").Value = "default"
xmlDoc.Save(filename)
Dim lastnode As XmlNode = childnode.SelectSingleNode("value")
lastnode.InnerText = txtResourceValue.Text
xmlDoc.Save(filename)
Label2.Text = "Resource File Updated Successfully."
End Sub
Screenshot