misnstt
asked on
Error message when Trying to Propagate Textbox with field from DataList in ASP.NET
I have a textbox on the page called "PayPeriodId".
I want the textbox to propagate from the PayPeriodId field of a DataList. I am using the Databound action but am getting the error. Please let me know what I need to change.
I want the textbox to propagate from the PayPeriodId field of a DataList. I am using the Databound action but am getting the error. Please let me know what I need to change.
THIS IS THE DATABOUND IN THE CS PAGE:
protected void DataList8_DataBound(object sender, EventArgs e)
{
PayPeriodId.Text = DataBinder.Eval(DataList8.DataItem, "PayPeriodId").ToString();
}
}
THIS IS THE TEXTBOX:
<asp:TextBox ID="PayPeriodId" runat="server"></asp:TextBox>
DataLists have multiple items, so you need to put this code in ItemDataBound. If you have a header or footer, you'll need to check for that as well, so you don't try to run the code there.
ASKER
Good Afternoon,
The textbox is located outside of the template that is what is making this so difficult. I changed it to the ItemDataBound but am still having a error. there are no Header or footers. The error is where it says DataList8.DataItem. I think the "DataItem" has to change.
protected void DataList8_ItemDataBound(ob ject sender, DataListItemEventArgs e)
{
PayPeriodId.Text = DataBinder.Eval(DataList8. DataItem, "PayPeriodId").ToString();
}
The textbox is located outside of the template that is what is making this so difficult. I changed it to the ItemDataBound but am still having a error. there are no Header or footers. The error is where it says DataList8.DataItem. I think the "DataItem" has to change.
protected void DataList8_ItemDataBound(ob
{
PayPeriodId.Text = DataBinder.Eval(DataList8.
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello I have been working on this project for a while. I am almost finished except for one difficult part. For me it is difficult but wouldnt be for you. I would like to pay you to show me how to do what I want since you appear very knowledgble. My direct e-mail is cbomik@hotmail.com if your interested. Thanks
Is this textbox inside a datalist itemtemplate? If it is you can simply assign the text property like this
<asp:Textbox id="PayPeriodId" runat="server" text='<%#Eval("PayPeriodId