How to edit text in text box on click of button?
My datalist code is:
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
piya pPosted Apr 25, 2014, 3:00 AM
{
Button btn = (Button)sender;
string id = btn.CommandArgument;
foreach (DataListItem item in datalist.Items)
{
TextBox tb = (TextBox)item.FindControl("txt");
if (tb.Text == id)
{
tb.ReadOnly = false;
tb.Enabled = true;
}
}
}
This is my aspx.cs code
here foreach line giving error after index 1
Error is null reference
Can you help me to change this code?
Abhay ShankerPosted Apr 25, 2014, 2:41 AM
Add another text box in Edit template
Add a button with commandName="Edit"
in datalist add OnEditCommand="DataList_EditCommand"
in .cs page
protected void DataList_EditCommand(object source,DataListCommandEventArgs e)
{
//Do your coding
}