0
例外が発生しました'dr ["hylValue"]' 'System.ArgumentException'タイプの例外がスローされました。 ItemDataBoundイベントでhylValueとhylNameを取得する方法は何でしょうか。カラム "hylValue"はテーブルに属していません
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string hylValue = "https://www.google.co.in/";
string hylName = "Google";
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr["hylValue"] = hylValue.Split(new string[] {"~#~"}, StringSplitOptions.None);
dr["hylName"] = hylName.Split(new string[] {"~#~"},StringSplitOptions.None);
dt.Rows.Add(dr);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DataTable tbl = (DataTable)e.Item.DataItem;
HyperLink hylFileUpload1 = (HyperLink)e.Item.FindControl("HyperLink1");
hylFileUpload1.Text = tbl.Rows[0]["hylValue"].ToString();
hylFileUpload1.NavigateUrl = tbl.Rows[0]["hylName"].ToString();
}
}
}
これは私ののaspxコード
<body>
<form id="form1" runat="server">
<div>
<a href="mailto:[email protected]" target="_blank">Sumit Patil</a>
<br /><br />
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
</div>
</form>