I am having a problem of adding a multiple template columns to a datagrid. What i want to do is that whenever the user clicks a button a new template column similar to the one in the existing datagrid is added to that datagrid in runtime.
I am using th code
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim st As String
Dim col As New TemplateColumn
dt = Session("state")
col = New TemplateColumn
col = DataGrid1.Columns.Item(3)
DataGrid1.Columns.AddAt(dt.Columns.Count - 2, col)
col.HeaderText = "Price " + CStr(dt.Columns.Count - 2) + " (Rs.)"
st = "Price" + CStr(dt.Columns.Count - 2)
dt.Columns.Add(st)
Session("state") = dt
DataGrid1.DataSource = dt
DataGrid1.DataBind()
End Sub
But Whenever i am executing i am finding that only one column is added. The next time i click the button then only the header text is changing and no extra column is added to the datagrid. Please suggest me how to add multiple template column. Also I have another problem....There is a label on the header template. Each time i add a column, I want to change the text of the label. So please help me out....
Bookmarks