Datagrid Update Problem

  • Thread starter Thread starter Ben Arthur
  • Start date Start date
B

Ben Arthur

Hi All,
I have a datagrid with one column as editable, and on edit command, the
column shows a textbox where users can make changes.However, my data for
that column is expected to be a couple of lines evyertime, and so i
would prefer to display a text area or something more
approproate...however i m unable to do that and get an error if i change
the textbox to textarea in my code...Any suggestions?
Thanks in advance,
Ben
P.S
the code inside the edit command:
int Id= (int)datagrid1.DataKeys[e.Item.ItemIndex];
string newMessage;
TextBox aBox= new TextBox();
aBox = (TextBox)(e.Item.Cells[5].Controls[0]);
newMessage = aBox.Text;
 
Private Sub datagrid1_PreRender(ByVal sender As System.Object, ByVal e As
System.EventArgs)

If datagrid1.EditItemIndex <> -1 Then

Dim tbx As TextBox

tbx = CType(datagrid1.Items(datagrid1.EditItemIndex).Cells(2).Controls(0),
TextBox)

tbx.Width = Unit.Parse("5cm")

tbx.Height = Unit.Parse("5cm")

tbx.Wrap = True

tbx.TextMode = TextBoxMode.MultiLine

End If

End Sub

I hope this helps!
 
Yes that worked...Thanks a lot....
I am pasting my C# version of the code below for C# coders...
public void dg1_PreRender(object sender, System.EventArgs e)

{
if (dg1.EditItemIndex!= -1 )
{
TextBox aTextBox = new TextBox();
aTextBox =
(TextBox)(dg1.Items[dg1.EditItemIndex].Cells[2].Controls[0]);
aTextBox.Width=Unit.Parse("5cm");
aTextBox.Height=Unit.Parse("4cm");
aTextBox.Wrap=true;
aTextBox.TextMode=TextBoxMode.MultiLine;
}
}

Thanks again,
Ben
 
Back
Top