In sql server2005 I have commodity type as int. In dropdownlist I loaded commodity type as string shown in code, when I bind to gridview I got commmodity type as int. I need to have string value in grid and int value in data base, how I can do?
Now I am getting int value in database(right) but int value in grid view also.
<asp:DropDownList ID="ddlcommodity" runat="server" >
<asp:ListItem Value="0">abc<asp:ListItem>
<asp:ListItem Value="1">def</asp:ListItem>
<asp:ListItem Value="2">ppp</asp:ListItem>
<asp:ListItem Value="3">qqq</asp:ListItem>
</asp:DropDownList>
protected void dgvcommodity_RowCommand(object sender, GridViewCommandEventArgs e)
{ //// try ////{ if (e.CommandName == "edit123")
{ if (btnsave.Text == "Save") {
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
btnsave.Text = "Update";
ddlcommodity.SelectedValue = dgvcommodity.DataKeys[row.RowIndex].Values["commodity"].ToString();
}