
| <telerik:RadGrid ID="RadGrid1" ShowStatusBar="true" Height="420px" EnableAJAX="true" |
| runat="server" AutoGenerateColumns="False" AllowSorting="true" AllowMultiRowSelection="False" |
| AllowPaging="true" GridLines="None" ShowFooter="true" |
| AllowFilteringByColumn="false" EnableDrag="false" |
| EnableHeaderContextMenu="false" TableLayout="auto" |
| AllowAutomaticDeletes="True" AllowAutomaticInserts="True" |
| AllowAutomaticUpdates="True" PageSize="10" |
| OnNeedDataSource="RadGrid1_NeedDataSource" |
| OnItemDataBound="RadGrid1_ItemDataBound" |
| OnUpdateCommand="RadGrid1_UpdateCommand" |
| OnInsertCommand="RadGrid1_InsertCommand" |
| OnDeleteCommand="RadGrid1_DeleteCommand" |
| onitemcommand="RadGrid1_ItemCommand" |
| > |
| protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) |
| { |
| // Perform insert |
| RadGrid1.MasterTableView.ClearEditItems(); |
| } |
Protected Sub rgd_OrderItems_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgd_OrderItems.ItemDataBound Dim IDOrder = Request.QueryString("IDOrder") Dim cn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ETP_OPS_ConnectionString").ToString) cn.Open() Dim SqlCmd As SqlCommand SqlCmd = New SqlCommand("SELECT ImageFilePath FROM vw_Orders_Items WHERE ([IDOrder] = @IDOrder)", cn) SqlCmd.Parameters.Add("@IDOrder", SqlDbType.NVarChar, 36).Value = IDOrder Dim ImageFilePath = CType(SqlCmd.ExecuteScalar, String) cn.Close() If TypeOf e.Item Is GridDataItem Then For Each item As GridDataItem In rgd_OrderItems.Items 'Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim img As Image = DirectCast(item.FindControl("ImageFilePath"), Image) If ImageFilePath.Contains(".jpg") _ Or ImageFilePath.Contains(".jpeg") _ Or ImageFilePath.Contains(".gif") _ Or ImageFilePath.Contains(".png") Then img.ImageUrl = ImageFilePath ElseIf ImageFilePath Like ("*.doc*") Then img.ImageUrl = "../../images/icon_word.gif" ElseIf ImageFilePath Like ("*.pdf*") Then img.ImageUrl = "../../images/icon_pdf.gif" Else img.ImageUrl = "../../images/icon_unknown.gif" End If 'item("ImageFilePath").Attributes.Add("onclick", "OPenPopuP('" + ImageFilePath + "');") Next End If|
Period |
Amount |
Column1 |
Column2 |
Column3 |
Column4 |
|
January |
33,445.00 |
textbox |
textbox |
textbox |
textbox |
|
February |
22,000.00 |
textbox |
textbox |
textbox |
textbox |
|
March |
12,000.00 |
textbox |
textbox |
textbox |
textbox |
|
April |
|
textbox |
textbox |
textbox |
textbox |
The dataset the gets binded to the grid would contain periodID,periodname,amount,column1ID,column1value,column2ID,column2value,column3ID,column3value...
. The periodID would be the datakey value for the grid and the columns from column1 to column4 would be input text boxes. I want to bind the columnID values to the grid columns( column1ID to column1 , column2ID to column2....
).The users will enter some value in columns say column1 and I want to save the value entered in textbox to the database table. But the parameters I need to save would be periodID,textbox input and columnID.
I have two questions here ,
1. Can I bind columnIDs to columns (here in particular when it is having textbox)
2. If the columnIDs can be binded to the grid, can those values be retrieved when the text change event in the grid is called to save data.
I hope I am clear on the explanation. Could you please help me in this.
Thanks,
Kaushik