|
Hi,
How to display images dynamically? am displaying Radio buttons dynamically.My requirement is beside each radio button I want to show image. Am reading data from Xml file and make it in Dataset then using DataView am reading one by one. pls see the code what I have written:
DataSet dsPaymentMethod = new DataSet();
dsPaymentMethod.ReadXml(strFilePath);
DataView dvForDisplay = dsPaymentMethods.Tables[0].DefaultView;
for (int i = 0; i < dvForDisplay.Count; i++)
{
rdb = new HtmlInputRadioButton();
img = new Bitmap(5, 5);
rdb.ID = dvForDisplay[i]["RadioButtonId"].ToString();
rdb.Value = dvForDisplay[i]["PaymentGateway"].ToString();
img = System.Drawing.Image.FromFile(@"D:\VSSNew\SourceCode\Telefonica.MSNOut\Telefonica.MSNOut.UI\images\logos\cards\visa.gif");
panelInternational.Controls.Add(rdb);
}
I have written above code. but it only showing Radio buttons not images. How can I display images? Is there any server side contorl equal to this html ;
Thanks
|
|
|
|
|
set text property of radio button to html code like " "
|
|
|
|
|
|
Hi,
Using MS.Net 1.1, I am developing a form to display fields into DataList.
Datalist has itemtemplate and Requirefiled validator and textbox & label.
Each field has associated with control e.g.Textbox with in Datalist.
There two enviroment ,Development and Testging.
In Testing Enviroment,Datalist displays fileds sometimes in currect order while othertimes in reverse of previous like First time-
Name <textbox>>
Sname <textbox>
Age <textbox>
While other time
Age <textbox>
Sname <textbox>
Name <textbox>
I am not using paging or sorting.with Repeat Direction=Horiz and Repeatcolumn =1
In Development enviroment it is fine.
Where could be the problem?
Thanks.
AshwinGupta
|
|
|
|
|
I would use an order by, you must want them in some sort of order
The order by clause should sort your problem anyway
|
|
|
|
|
i want use paypal concept.but i didnot knoe how to use using Encore.PayPal.API.if know the code replay to me.
|
|
|
|
|
|
hi,
I have see some examples on CodeProject and other sites.I have found AutosuggestBox but its paid.
I need to fetch the field value from database and need to show under a textbox div.
and want to select the values by using arrows keys(up and down) like a gooogle suggest.
if any one have already through with this problem please suggest me the solution.
Thanks
Amit Agarwal
|
|
|
|
|
|
|
Hello Friend!
I want to call a web service from java script.
the web service exits in different solution i.e., java script and web service are in different project/solution.
the following code i use
<asp:scriptmanager runat="server" id="scriptManagerId">
<scripts>
<asp:scriptreference path="CallWebServiceMethods.js">
<services>
<asp:servicereference path="http://localhost/AjaxJavaScriptWebService/WebService.asmx ">
.
.
.
Server Time
the script file i.e.,CallWebServiceMethods.js
function GetTime()
{
WebService.GetServerTime(SucceededCallback);
}
when i execute the program a java script error occurs-
'WebService' is undefined.
if web service is in same solution, then it executes correctly
please help me
modified on Thursday, April 24, 2008 6:10 AM
|
|
|
|
|
|
thank you
the code is working, but if the web method returns any dataset then how can i bind the dataset to data grid
|
|
|
|
|
Hi Friends,
I am using update panal for the dropdown list and a text box to avoid postback occuring. when "Others" is been selected from the dropdownlist the textbox will be visible. Once the textbox is visible i want to set focus to the textbox where in i am not able to do as it comes inside update panel. can u plz help me ASAP...
Ashwini
|
|
|
|
|
|
no that doesn work when textbox is inside updatepanel
Ashwini
|
|
|
|
|
find the control (textBox) in the update panel and then set the focus for it
.....
|
|
|
|
|
How to find the control? plz help me ASAP
Ashwini
|
|
|
|
|
check this
http://www.odetocode.com/articles/116.aspx
|
|
|
|
|
hi friends
i have gridview in which i add new row button using add row button click
and i also fill that grid and then save the data into database
i m using update panel and script manager for ajax implemantation.i m also maintaining the session.
the addnew row is working but when i click on save the gridview rowcount become Zero..
and the data filled up is lost..
so what is the solution for that
plz tell me.
Thanks
|
|
|
|
|
When is the gridview populated, it could be because the click event affects the gridview and resets it therefore no rows are there
|
|
|
|
|
firsttime gridview is populated at page load then
when i add new rows that is working fine and i call my save data function at save button click
it is ok or not
thanks
|
|
|
|
|
this is my aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" EnableEventValidation="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<script type="text/javascript" language="javascript">
function setSessionVal(val)
{
var ob=document.getElementById('tshf');
if (val=='Save')
{
<%=savedata();%>
//set Session["AddRow"]=val;
}
else
if(val=='AddRow')
{
ob.value=val;
//set Session["AddRow"]=val;
}
}
</script>
<body >
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="360" >
</asp:ScriptManager>
<asp:Label ID="lblmy" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" EnableViewState="false" >
<ContentTemplate>
<asp:HiddenField runat="server" ID="tshf" Value=""/>
<asp:GridView ID="grdnew" runat="server" EnableViewState="false" Style="z-index: 100; left: 53px; position: absolute;top: 81px" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Name"/>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" EnableViewState="true" Text='<%# Eval("Name")%>' Width ="100px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label2" runat="server" Text="ContactNo"/>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" EnableViewState="true" Text='<%# Eval("contactNo")%>' Width ="100px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label3" runat="server" Text="Email"/>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" EnableViewState="true" Text='<%# Eval("email")%>' Width ="100px"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label4" runat="server" Text="Designation"/>
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList runat="server" DataTextField="DesignationName" DataValueField="pkDesignationID" EnableViewState="true" ID="ddldesg" Width="100px"></asp:DropDownList>
<asp:TextBox ID="TextBox4" runat="server" EnableViewState="true" Text='<%# Eval("designation")%>' Width ="100px" Visible="false"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label5" runat="server" Text="Project"/>
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList runat="server" DataTextField="ProjectName" DataValueField="pkProjectID" EnableViewState="true" ID="ddlproject" Width="100px"></asp:DropDownList>
<asp:TextBox ID="TextBox5" runat="server" EnableViewState="true" Text='1' Width ="100px" Visible="false" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnAddRow" runat="server" Text="AddRow" OnClick="btnAddRow_Click" OnClientClick="javascript:setSessionVal('AddRow')" />
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Getting Data From Server.....
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>
|
|
|
|
|
this is my CS page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using MySql.Data.MySqlClient;
public partial class Default2 : System.Web.UI.Page
{
DataSet ds;
MySqlConnection mcon;
MySqlCommand mcmd;
MySqlDataAdapter mda;
DataTable dt;
DataRow dr;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// getdata();
btnAddNewRow();
btnAddNewRow();
fillddl();
}
else
{
lblmy.Text = grdnew.Rows.Count.ToString();
Session["AddRow"] = tshf.Value.ToString();
}
if ("AddRow" == (string)Session["AddRow"])
{
btnAddNewRow();
fillddl();
Session["AddRow"] = "";
tshf.Value = "";
}
}
protected void btnAddNewRow()
{
dt = CreateDataTable();
grdnew.DataSource = dt;
grdnew.DataBind();
Session["TimeSheet"] = "AddNew";
}
protected void btnDisRow()
{
}
protected DataTable CreateDataTable()
{
DataTable dtvalues = (DataTable)Session["DataTable"];
if (dtvalues == null)
{
dtvalues = new DataTable();
dtvalues.Columns.Add(new DataColumn("", typeof(string)));
dtvalues.Columns.Add(new DataColumn("Name", typeof(string)));
dtvalues.Columns.Add(new DataColumn("contactNo", typeof(string)));
dtvalues.Columns.Add(new DataColumn("email", typeof(string)));
dtvalues.Columns.Add(new DataColumn("designation", typeof(string)));
Session["DataTable"] = dtvalues;
}
else
{
dr = dtvalues.NewRow();
dtvalues.Rows.Add(dr);
Session["DataTable"] = dtvalues;
}
return dtvalues;
}
protected void fillddl()
{
datads("tbldesignation","ddldesg","TextBox4");
datads("tblproject", "ddlProject", "TextBox5");
}
public void datads(String tblname,String ddlname,String textName)
{
string cmdtext = "Select * from " + tblname + " ;";
mcon = new MySqlConnection("Database=tsmdemo;Server= 172.16.1.22;uid=root;pwd=tops123;");
mcon.Open();
mcmd = new MySqlCommand(cmdtext, mcon);
mda = new MySqlDataAdapter(mcmd);
ds = new DataSet();
mda.Fill(ds);
try
{
if ((String)Session["TimeSheet"] == "AddNew")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl(ddlname);
ddl.DataSource = ds;
ddl.DataBind();
}
}
if ((String)Session["TimeSheet"] == "Getdata")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl(ddlname);
ddl.DataSource = ds;
ddl.DataBind();
TextBox temp = (TextBox)row.FindControl(textName);
ddl.SelectedIndex = Convert.ToInt32(temp.Text);
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
ds.Dispose();
mda.Dispose();
mcmd.Dispose();
mcon.Dispose();
}
}
protected void savedata()
{
string cmdText;
mcon = new MySqlConnection("Database=tsmdemo;Server= 172.16.1.22;uid=root;pwd=tops123;");
try
{
mcon.Open();
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow gdr in grdnew.Rows)
{
string name = ((TextBox)gdr.FindControl("TextBox1")).Text;
string contactNo = ((TextBox)gdr.FindControl("TextBox2")).Text;
string email = ((TextBox)gdr.FindControl("TextBox3")).Text;
int designation = ((DropDownList)gdr.FindControl("ddldesg")).SelectedIndex;
cmdText = "INSERT INTO tblempinfo VALUES ('"
+ name + "','" + contactNo + "','" + email + "'," + Convert.ToString(designation + 1) + ")";
mcmd = new MySqlCommand(cmdText, mcon);
mcmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
mcmd.Dispose();
mcon.Dispose();
}
}
protected void getdata()
{
try
{
mcon = new MySqlConnection("Database=tsmdemo;Server= 172.16.1.22;uid=root;pwd=tops123;");
mcon.Open();
mcmd = new MySqlCommand("Select * from tblempinfo;", mcon);
mda = new MySqlDataAdapter(mcmd);
ds = new DataSet();
mda.Fill(ds);
dt = ds.Tables[0];
Session["DataTable"] = dt;
grdnew.DataSource = dt;
grdnew.DataBind();
Session["TimeSheet"] = "Getdata";
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
ds.Dispose();
mda.Dispose();
mcmd.Dispose();
mcon.Dispose();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
protected void btnAddRow_Click(object sender, EventArgs e)
{
}
}
|
|
|
|
|
How can I use sqltransaction when I am using account transafer in my web appliocation.
Here the requirement is ,I have to insert into 5 tables having same fields with limited columns.I know usage of transaction for inserting into a single table.
My example code is
conn = ConfigurationSettings.AppSettings("connstring".ToString)
sqlconn = New SqlClient.SqlConnection(conn)
sqlconn.Open()
' DG1.Visible = True
'Dim ds As New DataSet
Dim tr As SqlTransaction
Dim cmd As New SqlCommand
tr = sqlconn.BeginTransaction
cmd.Connection = sqlconn
cmd.Transaction = tr
Try
cmd.CommandText = "Update tbl_demand Set no_item = 4 where distcd=30"
cmd.ExecuteNonQuery()
tr.Commit()
Console.WriteLine("table updated successfully.")
Catch ex As Exception
tr.Rollback()
Console.WriteLine("Error: {1}", ex.Message)
Console.WriteLine("Error reported by {1}.", ex.Source)
Console.WriteLine("Money was not transfered.")
Finally
sqlconn.Close()
End Try
If I want to insert/update in different tables how can I commit/rollback on a single buttonclick_event.
Can anybody give me some idea?
kissy
|
|
|
|