Hi,
I am using a gridview in this grid-view when user select item then rate column display rate. and user make input of quantity.
not i want to column amount make calculation of rate and quantity column at the same time when user input amount.
plz give me a sample example.
whtever i did is...
with the above code i am able to display item from dropdown rate on selection of dropdownlist from database file.
now want to update order table when user input quantity.
Thanks
I am using a gridview in this grid-view when user select item then rate column display rate. and user make input of quantity.
not i want to column amount make calculation of rate and quantity column at the same time when user input amount.
plz give me a sample example.
whtever i did is...
<
telerik:RadGrid
ID
=
"radGrid1"
runat
=
"server"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
AllowMultiRowEdit
=
"True"
OnItemDataBound
=
"radGrid1_ItemDataBound"
OnNeedDataSource
=
"radGrid1_NeedDataSource"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
ShowFooter
=
"false"
CommandItemDisplay
=
"Top"
OnPreRender
=
"radGrid1_PreRender"
>
<
Columns
>
<
telerik:GridTemplateColumn
HeaderText
=
"Product Name"
UniqueName
=
"Product_Name"
>
<
ItemTemplate
>
<
asp:DropDownList
ID
=
"ddl1"
runat
=
"server"
AutoPostBack
=
"true"
DataTextField
=
"product_Name"
DataValueField
=
"product_Name"
OnSelectedIndexChanged
=
"ddl1_SelectedIndexChanged"
>
</
asp:DropDownList
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Product_rate"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblrate"
runat
=
"server"
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Product Quantity"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"txtQuantity"
runat
=
"server"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Product Amount"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblAmount"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
protected
void
ddl1_SelectedIndexChanged(
object
sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;
GridDataItem item = (GridDataItem)list.NamingContainer;
//display selected value of dropdown list.
//string str = list.SelectedValue;
//(item.FindControl("lblRate") as Label).Text = str;
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"chalk_hillConnectionString"
].ConnectionString);
con.Open();
SqlCommand cmd =
new
SqlCommand(
"select product_rate from product_detail where product_name='"
+ list.SelectedItem.Text +
"'"
, con);
SqlDataReader reader; ;
reader = cmd.ExecuteReader();
if
(reader.Read())
{
(item.FindControl(
"lblRate"
)
as
Label).Text = reader[
"product_rate"
].ToString();
}
}
protected
void
radGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
DropDownList list = (DropDownList)item.FindControl(
"ddl1"
);
list.Items.Insert(0,
new
ListItem(
"select"
,
"-1"
));
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"chalk_hillConnectionString"
].ConnectionString);
SqlDataAdapter da =
new
SqlDataAdapter();
da.SelectCommand =
new
SqlCommand(
"select product_name from product_detail"
, con);
DataSet ds =
new
DataSet();
da.Fill(ds);
list.DataSource = ds;
list.DataBind();
}
}
with the above code i am able to display item from dropdown rate on selection of dropdownlist from database file.
now want to update order table when user input quantity.
Thanks